forked from KolibriOS/kolibrios
Added 'StarTrek' game source code. The game was written in FASM for Win32. Theoretically could be ported for KolibriOS :-)
git-svn-id: svn://kolibrios.org@1812 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
parent
0555bd8c9a
commit
ea96aec626
BIN
programs/games/StarTrek/trunk/Bin/MsgTable.txt
Normal file
BIN
programs/games/StarTrek/trunk/Bin/MsgTable.txt
Normal file
Binary file not shown.
257
programs/games/StarTrek/trunk/Bin/ReadMe.txt
Normal file
257
programs/games/StarTrek/trunk/Bin/ReadMe.txt
Normal file
@ -0,0 +1,257 @@
|
||||
|
||||
* ----------------------------------------------- *
|
||||
* THIS DOCUMENT IS LOOKING BEST WITH COURIER FONT *
|
||||
* ----------------------------------------------- *
|
||||
|
||||
|
||||
CONTENTS OF THIS FOLDER:
|
||||
- README.TXT - THIS FILE
|
||||
- STARTREK32.EXE - GAME EXECUTABLE FILE
|
||||
- STARTREK.DOC - ORIGINAL GAME INSTRUCTIONS
|
||||
- MSGTABLE.TXT - GAME MESSAGES (ENCRYPTED)
|
||||
- DO NOT EDIT MSG TABLE - REMINDER NOT TO OPEN IT IN EDITOR
|
||||
|
||||
|
||||
1. MODIFICATIONS TO ORIGINAL VERSION OF THIS GAME
|
||||
===================================================
|
||||
|
||||
|
||||
WHEN I STARTED TESTING THE GAME, I NOTICED THAT NO MATTER HOW HARD
|
||||
I AM TRYING TO BEAT THE 'EMERITUS' LEVEL - THERE IS SIMPLY NOT MUCH
|
||||
LUCK ON MY SIDE. WELL, I DECIDED TO ADD SOME POWER-UPS TO REMEDY
|
||||
THIS SITUATION.
|
||||
|
||||
|
||||
1.1 WHEN 'DOCK' COMMAND IS EXECUTED SOMETIMES MORE PHOTON
|
||||
LAUNCHERS ARE ADDED, SO SHIP CAN FIRE MORE PHOTON TORPEDOES IN ONE
|
||||
BURST. THIS EVENT HAPPENS ONLY ONCE PER GAME (FOR NOW).
|
||||
|
||||
THE NUMBER OF TORPEDOES PER BURST IS INDICATED ON 'TORPEDOES' LINE
|
||||
IN SHORT RANGE SCAN REPORT. MAXIMUM NUMBER OF ADDED LAUNCHERS IS
|
||||
THREE, SO IN ALL SHIP CAN HAVE UP TO SIX TORPEDOES FIRED PER BURST!
|
||||
|
||||
|
||||
1.2 WHEN 'DOCK' COMMAND IS EXECUTED IT IS POSSIBLE SOMETIMES TO
|
||||
RECEIVE QUANTUM TORPEDOES INSTEAD OF NORMAL ONES. THESE ARE NEW
|
||||
WARHEADS DESIGNED BY STARFLEET ENGINEER CORPS. THE QUANTUM CHARGES
|
||||
DO NOT SUFFER THE LOSS OF TARGETING WHEN PASSING THROUGH SHIELDS AS
|
||||
MUCH AS NORMAL TORPEDOES. AND OF COURSE, THEY PACK QUITE A PUNCH!
|
||||
|
||||
"ENTERPRISE" WILL RECEIVE SIXTEEN QUANTUM CHARGES AND "FAERIE
|
||||
QUEENE" WILL GET EIGHT. THESE CHARGES MUST BE EXPENDED BEFORE THE
|
||||
NEXT DOCKING PROCEDURE, OTHERWISE THE TORPEDOES WILL NOT BE
|
||||
REFILLED BY THE BASE. SO, DO NOT SAVE YOUR QUANTUM TORPEDOERS! GET
|
||||
INTO SOME QUADRANT AND MAKE A SHOOTING GALLERY OUT OF POOR SUCKERS!
|
||||
ESPECIALLY IF YOU HAVE SIX PHOTON TUBES.
|
||||
|
||||
|
||||
I WAS THINKING TO ADD SOME NEW WAYS TO GATHER ENERGY IN GALAXY, BUT
|
||||
SO FAR NOTHING COMES TO MIND. IF YOU HAVE ANY IDEAS ON THAT I WILL
|
||||
BE GLAD TO HEAR IT.
|
||||
|
||||
|
||||
1.3 ANOTHER NICE TO HAVE MODIFICATION IS THAT OUTPUT HAS TRUE
|
||||
COLOURS. THESE COLOURS ARE NOT STANDARD WIN32 CONSOLE COLOURS,
|
||||
BUT IN FACT, MY CONSOLE WINDOW IS A REAL WIN32 WINDOW, SIMULATING A
|
||||
CONSOLE I/O.
|
||||
|
||||
|
||||
1.4 SOME DELAY ADDED WHEN OUTPUTTING LARGE AMOUNTS OF DATA - IT
|
||||
IMPROVES READABILITY, SINCE I HAVE NOT IMPLEMENTED THE SCROLLING OF
|
||||
MY CONSOLE WINDOW (FOR NOW).
|
||||
|
||||
|
||||
1.5. NEW 'LOG' COMMAND ADDED INTO THE GAME. IT ALLOWS SAVING ALL
|
||||
GAME I/O INTO THE FILE CALLED 'STARTREK.LOG'. THIS FILE IS RE-
|
||||
CREATED EACH GAME, SO IF YOU NEED TO ANALYSE ANY PREVIOUS GAMES YOU
|
||||
HAVE TO RENAME THAT FILE AFTER THE GAME.
|
||||
|
||||
|
||||
1.6 SINCE I HAVE TRUE COLOURS IN THE GAME I DECIDED TO IMPROVE
|
||||
THE GALAXY CHART. ALL QUADRANTS WHERE 'SRSCAN' COMMAND WAS GIVEN
|
||||
WILL BE HIGHLIGHTED WITH DIFFERENT COLOUR. IT MAY BE USEFUL IN
|
||||
LOCATING A PLANET. ALSO, THE SHIP'S QUADRANT IS HIGHLIGHTED TOO.
|
||||
|
||||
|
||||
|
||||
2. SOME STRATEGY HINTS
|
||||
======================
|
||||
|
||||
|
||||
"STAR TREK" IS A GAME OF STRATEGY. I GOT THAT WHILE PLAYING
|
||||
IT DURING MY TESTING PHASE - I WAS PLAYING FOR HOURS EVERY DAY!
|
||||
|
||||
I GOT A LOT OF BUGS FIXED, AND AT THE SAME TIME I GOT SOME INSIGHTS
|
||||
INTO THE GAME. MOST OF THESE CAME WITH A KNOWLEDGE OF READING THE
|
||||
SOURCE CODE FROM PDP-11. HOWEVER, I CAN ADD SOME OF MY OWN. AND,
|
||||
OF COURSE, SOME LUCK IS MUCH NEEDED, ESPECIALLY ON THE "EMERITUS"!
|
||||
|
||||
SO, LET'S BEGIN!..
|
||||
|
||||
|
||||
2.1 IMAGINE THAT YOU HEAR ON SUBSPACE, THAT A BASE IS UNDER
|
||||
ATTACK AND YOU REALISE THAT TO GET THERE AT WARP 5 OR EVEN AT WARP
|
||||
6 IS NOT POSSIBLE. YOU HAVE THE ENERGY, BUT THE MOVE WITH WARPS
|
||||
OVER 6 WILL DAMAGE THE ENGINES AND YOU'LL GET STRANDED OR YOU'LL
|
||||
HAVE TO DRAG AT WARP 4. IN SUCH A CASE I USE WARP 8, BUT I MAKE
|
||||
SHORT TRIPS - EACH TRIP IS NO LONGER THAN 5 SECTORS. THERE IS A
|
||||
PROBABILITY OF DAMAGING THE ENGINES, BUT THAT PROBABILITY IS MUCH
|
||||
LOWER FOR SHORT JUMPS. ALSO, GO WITH SHIELDS DOWN TO SAVE ENERGY.
|
||||
IF YOU GET TRACTORED - YOU'LL HAVE A CHANCE TO RAISE SHIELDS FOR
|
||||
BATTLE. IN FACT, ALWAYS LOWER SHIELDS, WHEN BATTLE IS OVER.
|
||||
|
||||
|
||||
2.2 IF YOU REALISE THAT BASE WILL BE DESTROYED AND YOU STILL IN
|
||||
A NEIGHBOURING QUADRANT AND NOT ENOUGH TIME TO GET TO BASE - 'HELP'
|
||||
COMMAND CAN BE USED TO JUMP STRAIGHT INTO DOCK. HOWEVER, THIS MAY
|
||||
END BADLY, BECAUSE 'HELP' COMMAND IS PRONE TO RE-MATERIALIZATION
|
||||
FAILURE AND YOU'LL LOSE THE GAME. ON THE OTHER HAND, JAMES T. KIRK
|
||||
LOVES TO RISK! AND YOU ARE BECOME HIM, REMEMBER?..
|
||||
|
||||
|
||||
2.3 WHEN YOU ENTER THE QUADRANT WITH ENEMIES - THEY ATTACK
|
||||
RIGHT AWAY. YOU CAN ATTACK WHEN THEIR ATTACK IS OVER, HOWEVER, YOU
|
||||
HAVE ONE CHANCE TO MOVE BEFORE ATTACKING, SO USE IT WISELY. FOR
|
||||
EXAMPLE, YOU CAN FLY INTO THE MIDDLE OF ENEMIES, SO YOUR WEAPONS
|
||||
WOULD BE MORE EFFECTIVE ON THE SHORT DISTANCE. IT WORKS FOR BOTH
|
||||
PHASERS (LESS ENERGY SPENT ON A BURST) AND TORPEDOES (PRECISION AND
|
||||
HIT ENERGY WILL BE INTENSIFIED).
|
||||
|
||||
|
||||
2.4 SIMPLE FACT: WHEN STAR IS HIT BY A TORPEDO - IT BECOMES A
|
||||
NOVA. NOVA DESTROYS (OR HEAVILY DAMAGES) ALL OBJECTS IN 8 ADJACENT
|
||||
SECTORS. YOU CAN USE IT IN BATTLE. IF YOU HAVE ONLY 2 TORPEDOES
|
||||
LEFT, BUT THERE ARE 5 KLINGONS IN THE QUADRANT, HOWEVER, THESE
|
||||
ENEMIES ARE ADJACENT TO TWO STARS. THEY ARE UNLUCKY ONES! FLY INTO
|
||||
A POSITION, WHERE YOUR TORPEDOES WILL SURELY HIT THOSE STARS AND
|
||||
FIRE! ENEMIES WILL BE DESTROYED (MOST LIKELY). THERE IS A SMALL
|
||||
PROBABILITY THAT NOVA CAN BECOME A SUPERNOVA - THAT WOULD BE BAD. I
|
||||
ONCE EXPERIENCED THAT IN MY TESTING.
|
||||
|
||||
|
||||
2.5 BEWARE OF ROMULANS! - THEY HAVE MORE POWER THAN MOST
|
||||
KLINGONS. ALSO, THEY USUALLY FIRE TORPEDOES - NOT A GOOD PROSPECT.
|
||||
TRY TO KILL OFF ROMULANS (AND COMMANDERS) FIRST WHEN IN BATTLE.
|
||||
|
||||
|
||||
2.6 ALWAYS TRY TO ENTER THE CORNER SECTOR OF A QUADRANT WITH
|
||||
ENEMIES OR CLOSE TO CORNER SECTOR. IT MINIMIZES THE ENEMY POWER
|
||||
AND THEY CANNOT INFLICT AS MUCH DAMAGE AS IF YOU ENTER THE SECTOR
|
||||
5-5. ALSO, IF YOU AT CORNER SECTOR - IT KEEPS THE THOLIAN FROM
|
||||
MOVING AND WEAVING ITS WEB.
|
||||
|
||||
|
||||
2.7 SOMETIMES YOU NEED A QUICK SCAN OF THE GALAXY. IT CAN BE
|
||||
DONE WITHOUT TOO MUCH ENERGY SPENT ON FLIGHT. SIMPLY FLY INTO ANY
|
||||
CORNER OF THE QUADRANT AND THEN MOVE JUST ONE SECTOR TO GET TO THE
|
||||
ADJACENT QUADRANT AND GIVE BOTH 'SRSCAN' AND 'LRSCAN' COMMANDS. BY
|
||||
DOING IT ONLY THREE TIMES (3 SECTORS TRAVELLED) YOU CAN SCAN FOUR
|
||||
QUADRANTS ON SHORT RANGE AND TWELVE ON LONG RANGE.
|
||||
|
||||
|
||||
2.8 AFTER THE BATTLE ALWAYS KEEP YOUR SHIELDS ON FULL OR CLOSE
|
||||
TO FULL. YOU CAN BE TRACTORED BY A COMMANDER AT ANY TIME AND YOU
|
||||
WILL NOT BE ABLE TO TRANSFER THE ENERGY - ONLY TO RAISE SHIELDS.
|
||||
|
||||
|
||||
2.9 HOW TO FIGHT A LOT OF KLINGONS? IMAGINE THAT YOU ENTER A
|
||||
QUADRANT AND IT HAS SEVEN KLINGONS OR MORE. EXPERIENCE SHOWS THAT
|
||||
TO KILL ALL ENEMIES WITH PHASER IS NOT FEASIBLE WITHOUT OVERHEATING
|
||||
PHASERS. IN THIS CASE THE MANUAL PHASER FIRE WILL HELP. USING
|
||||
THIS METHOD YOU CAN SEE HOW MUCH ENERGY IS NEEDED TO KILL EACH
|
||||
ENEMY. SIMPLY ENTER FOR EACH ENEMY SOME AMOUNT OF FIRE KEEPING IN
|
||||
MIND THAT PHASERS BEGIN OVERHEATING AT MORE THAN 1500 UNITS IN
|
||||
TOTAL. THE OVERHEATING IS HIGHLY RANDOM - I ONCE FIRED 2500 AT
|
||||
SUPER-COMMANDER IN A FAR DISTANCE (COULD NOT MOVE CLOSER) AND MY
|
||||
PHASERS WERE NOT OVERHEATED! SO, WHEN YOU ENTER THE MANUAL AMOUNTS
|
||||
FOR EACH ENEMY AND FIRE - IT WILL WEAKEN THE ENEMIES, SO THEY WILL
|
||||
NOT BE ABLE TO FIRE AS MUCH IN THEIR NEXT WAVE OF ATTACK. USUALLY,
|
||||
YOUR SECOND PHASER SHOT WILL KILL ALL SEVEN KLINGONS. YOUR RESULTS
|
||||
MAY VARY, HOWEVER! THAT'S WHY THIS GAME IS SO ADDICTIVE! ANYTHING
|
||||
CAN HAPPEN DURING BATTLE!
|
||||
|
||||
|
||||
2.10 IF THE ENEMY IS CLOSE TO BLACK HOLE (PREFERABLY 1 SECTOR
|
||||
DISTANCE) - IT IS POSSIBLE TO DISPLACE THAT ENEMY INTO A BLACK HOLE
|
||||
WITH A TORPEDO FIRED ON THE SAME VECTOR. I ONCE WAS IN A SITUATION
|
||||
DEPICTED BELOW AND WAS ABLE TO KILL SUPER-COMMANDER WITH JUST ONE
|
||||
NORMAL TORPEDO!
|
||||
|
||||
|
||||
. E . . S @ . . .
|
||||
|
||||
|
||||
|
||||
3. NEED FOR IMPROVEMENT
|
||||
=======================
|
||||
|
||||
|
||||
3.1 I WOULD BE HAPPY TO HEAR SOME NEW IDEAS ABOUT THE GAME. YOU
|
||||
CAN E-MAIL ME (asmguru62@hotmail.com) TO GIVE AN INSIGHT OR ADVICE.
|
||||
|
||||
|
||||
3.2 I WAS NOT HAPPY TO DISCOVER (READING THE SOURCE CODE) THAT
|
||||
COMMANDER'S TRACTOR BEAM WORKS ON A GREAT DISTANCES. BASICALLY,
|
||||
THE SHIP CAN BE PULLED FROM ONE CORNER OF THE GALAXY TO THE OTHER!!
|
||||
THAT DOES NOT SEEM LOGICAL TO ME. I WANTED TO ADJUST THE GAME, SO
|
||||
THE DISTANCE WILL BE A FACTOR, BUT I LEFT THAT AS IS - TO PRESERVE
|
||||
THE ORIGINAL IDEA FOR NOW.
|
||||
|
||||
|
||||
3.3 BUGS!! OF COURSE, I AM GLAD TO HEAR SOME BUG REPORTS. LET'S
|
||||
MAKE IT A NICE GAMING EXPERIENCE - 70s STYLE!.. DURING TESTING I
|
||||
HAVE SEEN SOME STRANGE ISSUES, HOWEVER, I WAS NOT ABLE TO REPRODUCE
|
||||
THESE IN A CONSISTENT MANNER.
|
||||
|
||||
|
||||
3.4 TAKE A LOOK AT POSITION BELOW:
|
||||
|
||||
1 2 3 4 5
|
||||
1 E * . . .
|
||||
2 . . . . .
|
||||
|
||||
TO MOVE TO SECTOR 2-2 THE SHIP NEEDS TO TRAVEL AT 45 DEGREE ANGLE
|
||||
DOWN AND TO THE RIGHT AND IT SEEMS LIKE NOTHING IN THE WAY. BEWARE
|
||||
OF SUCH CONDITION - IN MOST CASES THE SHIP WILL BE BLOCKED BY STAR
|
||||
AT SECTOR 1-2. I ANALYSED THE CODE AND IT SEEMS, WHEN SHIP MOVES,
|
||||
IT WILL APPROXIMATE ITS LOCATION TO THE NEAREST SECTOR WITH HALF
|
||||
SECTOR PRECISION. FOR EXAMPLE: SECTOR 1-1.5 WILL BE ROUNDED TO
|
||||
SECTOR 1-2 AND THIS WILL CAUSE COLLISION WITH OBJECT AT THAT SECTOR
|
||||
IF ANY. THAT SEEMS ILLOGICAL, AS SPOCK WOULD SAY. HALF OF THE
|
||||
SECTOR CANNOT BE COMPARED WITH THE SHIP'S LENGTH TO BE ABLE TO
|
||||
COLLIDE WITH ANYTHING. I ALSO, LEFT THAT FACT INTACT FROM ORIGINAL
|
||||
CODE. SIMPLY DO NOT PLOT YOUR COURSE TOO CLOSE TO OTHER OBJECTS.
|
||||
|
||||
THE SAME CONDITION EXISTS FOR TORPEDOES TOO, BECAUSE THE SAME CODE
|
||||
IS USED TO MOVE A TORPEDO.
|
||||
|
||||
|
||||
|
||||
4. FASM SOURCE CODE
|
||||
===================
|
||||
|
||||
|
||||
I HAVE INSERTED THE ORIGINAL COPYRIGHT NOTE FROM PDP-11 FORTRAN
|
||||
SOURCE. YOU CAN MODIFY THE CODE, BIT ONLY FOR FUN - NOT FOR PROFIT.
|
||||
|
||||
THE SOURCE CODE WAS NOT WRITTEN TO BE FAST. IT WAS WRITTEN TO MIMIC
|
||||
EXACTLY THE LOGIC OF FORTRAN SOURCE. PLEASE DO NOT ASK ME TO MAKE
|
||||
OPTIMIZATIONS IN THE CODE - IT WILL NEVER BE DONE. I USED MY OWN
|
||||
IDE FOR FASM TO CREATE THAT CODE. YOU CAN LOOK AT THE DATES IN
|
||||
FILES AND FIGURE OUT HOW MUCH TIME IT TOOK TO WRITE THAT CODE. THIS
|
||||
WAS MY THIRD (!) ATTEMPT TO RE-CREATE ONE OF MY FAVOURITE GAMES.
|
||||
|
||||
IN THE FIRST ATTEMPT I TRIED TO RE-DESIGN THE ORIGINAL SOURCE TO BE
|
||||
MORE STRUCTURED. NO NEED TO SAY - IT FAILED MISERABLY! THE LOGIC
|
||||
IN SOME CASES WAS LOST.
|
||||
|
||||
IN THE SECOND ATTEMPT I WROTE THE FASM CODE TO MIMIC FORTRAN CODE
|
||||
EXACTLY. HOWEVER, I FAILED TO SEE THAT THERE SHOULD BE TWO THREADS.
|
||||
ONE THREAD SHOULD RUN THE CONSOLE WINDOW AND THE OTHER ONE SHOULD
|
||||
DEAL WITH GAME LOGIC: QUESTIONS AND ANSWERS FROM CONSOLE.
|
||||
|
||||
WELL, THIRD TIME'S A CHARM!
|
||||
|
||||
|
||||
AsmGuru62
|
||||
August 23, 2009
|
1436
programs/games/StarTrek/trunk/Bin/startrek.doc
Normal file
1436
programs/games/StarTrek/trunk/Bin/startrek.doc
Normal file
File diff suppressed because it is too large
Load Diff
182
programs/games/StarTrek/trunk/Globals.Inc
Normal file
182
programs/games/StarTrek/trunk/Globals.Inc
Normal file
@ -0,0 +1,182 @@
|
||||
; --------------------------------------------------------------------------
|
||||
; Global variables
|
||||
; --------------------------------------------------------------------------
|
||||
|
||||
glb_GameThreadBusy BOOL 1
|
||||
glb_Instance HINSTANCE 0
|
||||
glb_Allocator HANDLE 0
|
||||
glb_MainWnd HWND 0
|
||||
glb_Font HFONT 0
|
||||
glb_FPU_Int32 INT32 0
|
||||
glb_Score INT32 0
|
||||
glb_CharSize rb SIZE.size
|
||||
glb_pConsole PTConsole 0
|
||||
glb_pCmdBuf PTCmdBuf 0
|
||||
glb_pRawMsgBuffer PCHAR 0
|
||||
glb_pMsgItems PPCHAR 0
|
||||
glb_NumMsgItems COUNT 0
|
||||
glb_pGameData PTGameData 0
|
||||
glb_pCommon PTCommon 0
|
||||
glb_pMersenne PTRandom 0
|
||||
glb_pLog PVOID 0
|
||||
glb_MOVED BYTE 0
|
||||
glb_LogEnabled BYTE 0
|
||||
glb_bEmExit BYTE 0
|
||||
glb_AttrCondition BYTE ATTR_COND_GREEN, ATTR_COND_RED, ATTR_COND_YELLOW, ATTR_COND_GREEN
|
||||
|
||||
glb_ObjectMap BYTE CHAR_ROMULAN, CHAR_KLINGON, CHAR_COMMANDER, \
|
||||
CHAR_SCOM, CHAR_ASTERISK, CHAR_PLANET, CHAR_STARBASE, \
|
||||
CHAR_BLACK_HOLE, CHAR_THOLIAN
|
||||
|
||||
glb_Plaque BYTE PLAQUE_END_OF_LINE,PLAQUE_END_OF_LINE,\
|
||||
PLAQUE_END_OF_LINE,PLAQUE_END_OF_LINE,\
|
||||
64,' ',50,'E',PLAQUE_END_OF_LINE,\
|
||||
38,' ',3,'E',22,' ',PLAQUE_STRING,6,'E : :',41,' ',1,':',2,' ',1,'E',PLAQUE_END_OF_LINE,\
|
||||
36,' ',2,'E',3,' ',3,'E',19,' ',PLAQUE_STRING,6,'E : :',19,' ',\
|
||||
PLAQUE_STRING,8,'NCC-1701',14,' ',PLAQUE_STRING,4,': E',PLAQUE_END_OF_LINE,\
|
||||
20,' ',16,'E',8,' ',15,'E',4,' ',PLAQUE_STRING,6,'E : :',41,' ',PLAQUE_STRING,3,': E',\
|
||||
PLAQUE_END_OF_LINE,\
|
||||
21,' ',1,'E',37,' ',1,'E',4,' ',48,'E',PLAQUE_END_OF_LINE,\
|
||||
22,' ',9,'E',15,' ',13,'E',17,' ',PLAQUE_STRING,4,'E E',PLAQUE_END_OF_LINE,\
|
||||
31,' ',7,'E',3,' ',5,'E',4,' ',1,'E',10,' ',1,'E',14,' ',PLAQUE_STRING,4,'E E',PLAQUE_END_OF_LINE,\
|
||||
38,' ',3,'E',11,' ',1,'E',10,' ',1,'E',12,' ',PLAQUE_STRING,4,'E E',PLAQUE_END_OF_LINE,\
|
||||
55,' ',1,'E',9,' ',1,'E',10,' ',PLAQUE_STRING,4,'E E',PLAQUE_END_OF_LINE,\
|
||||
57,' ',13,'E',6,' ',PLAQUE_STRING,4,'E E',PLAQUE_END_OF_LINE,\
|
||||
54,' ',3,'E',1,' ',1,':',11,' ',7,'E',2,' ',8,'E',PLAQUE_END_OF_LINE,\
|
||||
52,' ',1,':',1,'E',4,' ',1,':',17,' ',4,'E',7,' ',1,'E',PLAQUE_END_OF_LINE,\
|
||||
51,' ',PLAQUE_STRING,8,')-E -:',5,'-',23,' ',1,'E',PLAQUE_END_OF_LINE,\
|
||||
52,' ',1,':',1,'E',4,' ',1,':',28,' ',1,'E',PLAQUE_END_OF_LINE,\
|
||||
54,' ',2,'E',2,' ',1,':',20,' ',8,'E',PLAQUE_END_OF_LINE,\
|
||||
56,' ',23,'E',PLAQUE_END_OF_LINE,\
|
||||
PLAQUE_END_OF_LINE,PLAQUE_END_OF_LINE,PLAQUE_END_OF_LINE,\
|
||||
55,' ',PLAQUE_STRING,19,'U. S. S. ENTERPRISE',PLAQUE_END_OF_LINE,\
|
||||
PLAQUE_END_OF_LINE,PLAQUE_END_OF_LINE,PLAQUE_END_OF_LINE,PLAQUE_END_OF_LINE,\
|
||||
34,' ',PLAQUE_STRING,43,'FOR DEMONSTRATING OUTSTANDING ABILITY AS A ',\
|
||||
PLAQUE_STRING,16,'STARSHIP CAPTAIN',PLAQUE_END_OF_LINE,PLAQUE_END_OF_LINE,\
|
||||
48,' ',PLAQUE_STRING,32,'STARFLEET COMMAND BESTOWS TO YOU',PLAQUE_END_OF_LINE,\
|
||||
PLAQUE_END_OF_LINE,PLAQUE_INSERT_NAME,PLAQUE_END_OF_LINE,\
|
||||
59,' ',PLAQUE_STRING,11,'THE RANK OF',PLAQUE_END_OF_LINE,PLAQUE_END_OF_LINE,\
|
||||
55,' ',PLAQUE_STRING,20,'"COMMODORE EMERITUS"',PLAQUE_END_OF_LINE,PLAQUE_END_OF_LINE,\
|
||||
58,' ',PLAQUE_INSERT_LEVEL,PLAQUE_STRING,6,' LEVEL',PLAQUE_END_OF_LINE,PLAQUE_END_OF_LINE,\
|
||||
54,' ',PLAQUE_STRING,12,'THIS DAY OF ',PLAQUE_INSERT_DATE,PLAQUE_END_OF_LINE,\
|
||||
PLAQUE_END_OF_LINE,56,' ',PLAQUE_STRING,13,'YOUR SCORE: ',PLAQUE_INSERT_SCORE,\
|
||||
PLAQUE_END_OF_LINE,PLAQUE_END_OF_LINE,\
|
||||
52,' ',PLAQUE_STRING,24,'KLINGONS PER STARDATE: ',PLAQUE_INSERT_KLRATE,\
|
||||
PLAQUE_END_OF_LINE,PLAQUE_END_OF_ALL
|
||||
|
||||
align 2
|
||||
str_MainWndClass du 'SST32-FASM',0
|
||||
str_MainWndTitle du 'STAR TREK',0
|
||||
str_FontFace du 'Courier',0
|
||||
str_CharSizeText du 'Mj',0
|
||||
str_SetDirFailed du 'Unable to Set Current Directory. Please check permissions.',0
|
||||
str_MsgFileName du 'MsgTable.txt',0
|
||||
str_LogFileName du 'STARTREK.LOG',0
|
||||
str_FileMask du '*.TRK',0
|
||||
str_THOLIANX db 'THOLIANX',0
|
||||
str_TRK db '.TRK',0
|
||||
str_CmdListGames db '?.TRK',0
|
||||
str_EmSaveGame db 'EMSAVE.TRK',0
|
||||
str_PlaqueFile db 'PLAQUE.TXT',0
|
||||
|
||||
align 16
|
||||
glb_dbl_2e31 DOUBLE 2147483648.0
|
||||
glb_dbl_2e32 DOUBLE 4294967296.0
|
||||
glb_dbl_Ten DOUBLE 10.0
|
||||
glb_dbl_FpuPopper DOUBLE 0.0
|
||||
glb_dbl_0dot0625 DOUBLE 0.0625
|
||||
glb_dbl_0dot08 DOUBLE 0.08
|
||||
glb_dbl_0dot095 DOUBLE 0.095
|
||||
glb_dbl_0dot1 DOUBLE 0.1
|
||||
glb_dbl_0dot01 DOUBLE 0.01
|
||||
glb_dbl_0dot001 DOUBLE 0.001
|
||||
glb_dbl_0dot2 DOUBLE 0.2
|
||||
glb_dbl_0dot02 DOUBLE 0.02
|
||||
glb_dbl_0dot00001 DOUBLE 0.00001
|
||||
glb_dbl_0dot2777 DOUBLE 0.2777
|
||||
glb_dbl_0dot1777777777 DOUBLE 0.1777777777
|
||||
glb_dbl_0dot15 DOUBLE 0.15
|
||||
glb_dbl_0dot015 DOUBLE 0.015
|
||||
glb_dbl_0dot5 DOUBLE 0.5
|
||||
glb_dbl_0dot5235998 DOUBLE 0.5235998
|
||||
glb_dbl_0dot5235988 DOUBLE 0.5235988
|
||||
glb_dbl_0dot3 DOUBLE 0.3
|
||||
glb_dbl_0dot03 DOUBLE 0.03
|
||||
glb_dbl_0dot333 DOUBLE 0.3333333333
|
||||
glb_dbl_1dot5 DOUBLE 1.5
|
||||
glb_dbl_10dot5 DOUBLE 10.5
|
||||
glb_dbl_2dot5 DOUBLE 2.5
|
||||
glb_dbl_1dot2 DOUBLE 1.2
|
||||
glb_dbl_1dot23 DOUBLE 1.23
|
||||
glb_dbl_1dot4142 DOUBLE 1.4142
|
||||
glb_dbl_1dot57079633 DOUBLE 1.57079633
|
||||
glb_dbl_1dot01 DOUBLE 1.01
|
||||
glb_dbl_1dot90985932 DOUBLE 1.90985932
|
||||
glb_dbl_0dot04 DOUBLE 0.04
|
||||
glb_dbl_0dot4 DOUBLE 0.4
|
||||
glb_dbl_0dot45 DOUBLE 0.45
|
||||
glb_dbl_0dot49 DOUBLE 0.49
|
||||
glb_dbl_0dot05 DOUBLE 0.05
|
||||
glb_dbl_0dot005 DOUBLE 0.005
|
||||
glb_dbl_0dot00038 DOUBLE 0.00038
|
||||
glb_dbl_0dot006 DOUBLE 0.006
|
||||
glb_dbl_0dot75 DOUBLE 0.75
|
||||
glb_dbl_0dot77 DOUBLE 0.77
|
||||
glb_dbl_0dot65 DOUBLE 0.65
|
||||
glb_dbl_0dot6 DOUBLE 0.6
|
||||
glb_dbl_0dot89 DOUBLE 0.89
|
||||
glb_dbl_0dot8 DOUBLE 0.8
|
||||
glb_dbl_0dot9 DOUBLE 0.9
|
||||
glb_dbl_0dot99 DOUBLE 0.99
|
||||
glb_dbl_9dot99 DOUBLE 9.99
|
||||
glb_dbl_0dot98 DOUBLE 0.98
|
||||
glb_dbl_0dot995 DOUBLE 0.995
|
||||
glb_dbl_DOCKFAC DOUBLE 0.25
|
||||
glb_dbl_100 DOUBLE 100.0
|
||||
glb_dbl_200 DOUBLE 200.0
|
||||
glb_dbl_270 DOUBLE 270.0
|
||||
glb_dbl_66dot666 DOUBLE 66.666666666
|
||||
glb_dbl_2 DOUBLE 2.0
|
||||
glb_dbl_20 DOUBLE 20.0
|
||||
glb_dbl_3 DOUBLE 3.0
|
||||
glb_dbl_31 DOUBLE 31.0
|
||||
glb_dbl_39dot95 DOUBLE 39.95
|
||||
glb_dbl_4 DOUBLE 4.0
|
||||
glb_dbl_4dot5 DOUBLE 4.5
|
||||
glb_dbl_5 DOUBLE 5.0
|
||||
glb_dbl_6 DOUBLE 6.0
|
||||
glb_dbl_8 DOUBLE 8.0
|
||||
glb_dbl_25 DOUBLE 25.0
|
||||
glb_dbl_125 DOUBLE 125.0
|
||||
glb_dbl_50 DOUBLE 50.0
|
||||
glb_dbl_150 DOUBLE 150.0
|
||||
glb_dbl_950 DOUBLE 950.0
|
||||
glb_dbl_7 DOUBLE 7.0
|
||||
glb_dbl_7dot5 DOUBLE 7.5
|
||||
glb_dbl_9 DOUBLE 9.0
|
||||
glb_dbl_7dot853981634 DOUBLE 7.853981634
|
||||
glb_dbl_15 DOUBLE 15.0
|
||||
glb_dbl_12 DOUBLE 12.0
|
||||
glb_dbl_1175 DOUBLE 1175.0
|
||||
glb_dbl_75 DOUBLE 75.0
|
||||
glb_dbl_300 DOUBLE 300.0
|
||||
glb_dbl_30 DOUBLE 30.0
|
||||
glb_dbl_3000 DOUBLE 3000.0
|
||||
glb_dbl_400 DOUBLE 400.0
|
||||
glb_dbl_500 DOUBLE 500.0
|
||||
glb_dbl_600 DOUBLE 600.0
|
||||
glb_dbl_700 DOUBLE 700.0
|
||||
glb_dbl_800 DOUBLE 800.0
|
||||
glb_dbl_7200 DOUBLE 7200.0
|
||||
glb_dbl_450 DOUBLE 450.0
|
||||
glb_dbl_1000 DOUBLE 1000.0
|
||||
glb_dbl_5000 DOUBLE 5000.0
|
||||
glb_dbl_2500 DOUBLE 2500.0
|
||||
glb_dbl_1400 DOUBLE 1400.0
|
||||
glb_dbl_1500 DOUBLE 1500.0
|
||||
glb_dbl_1250 DOUBLE 1250.0
|
||||
glb_dbl_1E38 DOUBLE 1e38
|
||||
glb_dbl_3E_neg_5 DOUBLE 3e-5
|
||||
glb_dbl_KlingonsPerDate DOUBLE 0.0
|
||||
|
||||
; --- EOF ---
|
680
programs/games/StarTrek/trunk/Imports.Inc
Normal file
680
programs/games/StarTrek/trunk/Imports.Inc
Normal file
@ -0,0 +1,680 @@
|
||||
|
||||
; Import Section
|
||||
|
||||
dd 0, 0, 0, RVA kernel32, RVA kernel32tbl
|
||||
dd 0, 0, 0, RVA user32, RVA user32tbl
|
||||
dd 0, 0, 0, RVA gdi32, RVA gdi32tbl
|
||||
dd 0, 0, 0, 0, 0
|
||||
|
||||
kernel32tbl:
|
||||
;{W32}
|
||||
GetLocalTime dd RVA _GetLocalTime
|
||||
;{W32}
|
||||
SetFilePointer dd RVA _SetFilePointer
|
||||
;{W32}
|
||||
GetFileAttributes dd RVA _GetFileAttributes
|
||||
;{W32}
|
||||
SetCurrentDir dd RVA _SetCurrentDir
|
||||
;{W32}
|
||||
GetConsoleScrBufInfo dd RVA _GetConsoleScrBufInfo
|
||||
;{W32}
|
||||
GetConsoleMode dd RVA _GetConsoleMode
|
||||
;{W32}
|
||||
GetStdHandle dd RVA _GetStdHandle
|
||||
;{W32}
|
||||
FreeConsole dd RVA _FreeConsole
|
||||
;{W32}
|
||||
AllocConsole dd RVA _AllocConsole
|
||||
;{W32}
|
||||
CreateThread dd RVA _CreateThread
|
||||
;{W32}
|
||||
Sleep dd RVA _Sleep
|
||||
;{W32}
|
||||
MulDiv dd RVA _MulDiv
|
||||
;{W32}
|
||||
VirtualFree dd RVA _VirtualFree
|
||||
;{W32}
|
||||
VirtualAlloc dd RVA _VirtualAlloc
|
||||
;{W32}
|
||||
GetFileSize dd RVA _GetFileSize
|
||||
;{W32}
|
||||
WriteFile dd RVA _WriteFile
|
||||
;{W32}
|
||||
ReadFile dd RVA _ReadFile
|
||||
;{W32}
|
||||
CloseHandle dd RVA _CloseHandle
|
||||
;{W32}
|
||||
CreateFile dd RVA _CreateFile
|
||||
;{W32}
|
||||
CreateFileAnsi dd RVA _CreateFileAnsi
|
||||
;{W32}
|
||||
GetTickCount dd RVA _GetTickCount
|
||||
;{W32}
|
||||
FindClose dd RVA _FindClose
|
||||
;{W32}
|
||||
FindNextFile dd RVA _FindNextFile
|
||||
;{W32}
|
||||
FindFirstFile dd RVA _FindFirstFile
|
||||
;{W32}
|
||||
GetProcessHeap dd RVA _GetProcessHeap
|
||||
;{W32}
|
||||
GetModuleFileName dd RVA _GetModuleFileName
|
||||
;{W32}
|
||||
OutputDebugString dd RVA _OutputDebugString
|
||||
;{W32}
|
||||
HeapCreate dd RVA _HeapCreate
|
||||
;{W32}
|
||||
HeapAlloc dd RVA _HeapAlloc
|
||||
;{W32}
|
||||
HeapReAlloc dd RVA _HeapReAlloc
|
||||
;{W32}
|
||||
HeapFree dd RVA _HeapFree
|
||||
;{W32}
|
||||
HeapDestroy dd RVA _HeapDestroy
|
||||
;{W32}
|
||||
GetModuleHandle dd RVA _GetModuleHandle
|
||||
;{W32}
|
||||
ExitProcess dd RVA _ExitProcess
|
||||
dd 0
|
||||
|
||||
user32tbl:
|
||||
;{W32}
|
||||
OffsetRect dd RVA _OffsetRect
|
||||
;{W32}
|
||||
AdjustWindowRect dd RVA _AdjustWindowRect
|
||||
;{W32}
|
||||
MessageBeep dd RVA _MessageBeep
|
||||
;{W32}
|
||||
GetCursorPos dd RVA _GetCursorPos
|
||||
;{W32}
|
||||
TrackPopupMenu dd RVA _TrackPopupMenu
|
||||
;{W32}
|
||||
AppendMenu dd RVA _AppendMenu
|
||||
;{W32}
|
||||
DestroyMenu dd RVA _DestroyMenu
|
||||
;{W32}
|
||||
CreatePopupMenu dd RVA _CreatePopupMenu
|
||||
;{W32}
|
||||
GetFocus dd RVA _GetFocus
|
||||
;{W32}
|
||||
GetWindowTextLen dd RVA _GetWindowTextLen
|
||||
;{W32}
|
||||
GetWindowText dd RVA _GetWindowText
|
||||
;{W32}
|
||||
GetDlgItem dd RVA _GetDlgItem
|
||||
;{W32}
|
||||
PostMessage dd RVA _PostMessage
|
||||
;{W32}
|
||||
SendMessage dd RVA _SendMessage
|
||||
;{W32}
|
||||
InflateRect dd RVA _InflateRect
|
||||
;{W32}
|
||||
EndDialog dd RVA _EndDialog
|
||||
;{W32}
|
||||
DlgBoxParam dd RVA _DlgBoxParam
|
||||
;{W32}
|
||||
GetSystemMetrics dd RVA _GetSystemMetrics
|
||||
;{W32}
|
||||
DrawIcon dd RVA _DrawIcon
|
||||
;{W32}
|
||||
DrawText dd RVA _DrawText
|
||||
;{W32}
|
||||
ReleaseCapture dd RVA _ReleaseCapture
|
||||
;{W32}
|
||||
SetCapture dd RVA _SetCapture
|
||||
;{W32}
|
||||
SetWindowText dd RVA _SetWindowText
|
||||
;{W32}
|
||||
SetCursor dd RVA _SetCursor
|
||||
;{W32}
|
||||
ReleaseDC dd RVA _ReleaseDC
|
||||
;{W32}
|
||||
GetDC dd RVA _GetDC
|
||||
;{W32}
|
||||
FrameRect dd RVA _FrameRect
|
||||
;{W32}
|
||||
FillRect dd RVA _FillRect
|
||||
;{W32}
|
||||
EndPaint dd RVA _EndPaint
|
||||
;{W32}
|
||||
BeginPaint dd RVA _BeginPaint
|
||||
;{W32}
|
||||
UpdateWindow dd RVA _UpdateWindow
|
||||
;{W32}
|
||||
PostQuitMessage dd RVA _PostQuitMessage
|
||||
;{W32}
|
||||
LoadBitmap dd RVA _LoadBitmap
|
||||
;{W32}
|
||||
LoadImage dd RVA _LoadImage
|
||||
;{W32}
|
||||
LoadIcon dd RVA _LoadIcon
|
||||
;{W32}
|
||||
LoadCursor dd RVA _LoadCursor
|
||||
;{W32}
|
||||
GetWindowRect dd RVA _GetWindowRect
|
||||
;{W32}
|
||||
GetClientRect dd RVA _GetClientRect
|
||||
;{W32}
|
||||
ShowWindow dd RVA _ShowWindow
|
||||
;{W32}
|
||||
CreateWindowEx dd RVA _CreateWindowEx
|
||||
;{W32}
|
||||
DefWindowProc dd RVA _DefWindowProc
|
||||
;{W32}
|
||||
RegisterClass dd RVA _RegisterClass
|
||||
;{W32}
|
||||
GetClassInfo dd RVA _GetClassInfo
|
||||
;{W32}
|
||||
SetWindowLong dd RVA _SetWindowLong
|
||||
;{W32}
|
||||
GetWindowLong dd RVA _GetWindowLong
|
||||
;{W32}
|
||||
GetMessage dd RVA _GetMessage
|
||||
;{W32}
|
||||
DispatchMessage dd RVA _DispatchMessage
|
||||
;{W32}
|
||||
TranslateMessage dd RVA _TranslateMessage
|
||||
;{W32}
|
||||
TranslateAccelerator dd RVA _TranslateAccelerator
|
||||
;{W32}
|
||||
CreateAcceleratorTable dd RVA _CreateAcceleratorTable
|
||||
;{W32}
|
||||
InvalidateRect dd RVA _InvalidateRect
|
||||
;{W32}
|
||||
MoveWindow dd RVA _MoveWindow
|
||||
;{W32}
|
||||
IsWindowVisible dd RVA _IsWindowVisible
|
||||
;{W32}
|
||||
MessageBox dd RVA _MessageBox
|
||||
dd 0
|
||||
|
||||
gdi32tbl:
|
||||
;{W32}
|
||||
TextOut dd RVA _TextOut
|
||||
;{W32}
|
||||
MoveToEx dd RVA _MoveToEx
|
||||
;{W32}
|
||||
SetTextAlign dd RVA _SetTextAlign
|
||||
;{W32}
|
||||
BitBlt dd RVA _BitBlt
|
||||
;{W32}
|
||||
CreateCompatibleBitmap dd RVA _CreateCompatibleBitmap
|
||||
;{W32}
|
||||
DeleteDC dd RVA _DeleteDC
|
||||
;{W32}
|
||||
SetTextColor dd RVA _SetTextColor
|
||||
;{W32}
|
||||
CreatePatternBrush dd RVA _CreatePatternBrush
|
||||
;{W32}
|
||||
GetStockObject dd RVA _GetStockObject
|
||||
;{W32}
|
||||
CreatePen dd RVA _CreatePen
|
||||
;{W32}
|
||||
Polyline dd RVA _Polyline
|
||||
;{W32}
|
||||
CreateSolidBrush dd RVA _CreateSolidBrush
|
||||
;{W32}
|
||||
DeleteObject dd RVA _DeleteObject
|
||||
;{W32}
|
||||
CreateFontIndirect dd RVA _CreateFontIndirect
|
||||
;{W32}
|
||||
GetDeviceCaps dd RVA _GetDeviceCaps
|
||||
;{W32}
|
||||
GetTextExtentPoint32 dd RVA _GetTextExtentPoint32
|
||||
;{W32}
|
||||
SetBkMode dd RVA _SetBkMode
|
||||
;{W32}
|
||||
SelectObject dd RVA _SelectObject
|
||||
;{W32}
|
||||
CreateCompatibleDC dd RVA _CreateCompatibleDC
|
||||
dd 0
|
||||
|
||||
; --- Modules
|
||||
|
||||
kernel32 db 'KERNEL32.DLL', 0
|
||||
user32 db 'USER32.DLL', 0
|
||||
gdi32 db 'GDI32.DLL', 0
|
||||
|
||||
; --- Table
|
||||
|
||||
align 2
|
||||
_GetLocalTime dw 0
|
||||
db 'GetLocalTime',0
|
||||
|
||||
align 2
|
||||
_SetFilePointer dw 0
|
||||
db 'SetFilePointer',0
|
||||
|
||||
align 2
|
||||
_GetFileAttributes dw 0
|
||||
db 'GetFileAttributesA',0
|
||||
|
||||
align 2
|
||||
_SetCurrentDir dw 0
|
||||
db 'SetCurrentDirectoryW',0
|
||||
|
||||
align 2
|
||||
_OffsetRect dw 0
|
||||
db 'OffsetRect',0
|
||||
|
||||
align 2
|
||||
_GetConsoleScrBufInfo dw 0
|
||||
db 'GetConsoleScreenBufferInfo',0
|
||||
|
||||
align 2
|
||||
_GetConsoleMode dw 0
|
||||
db 'GetConsoleMode',0
|
||||
|
||||
align 2
|
||||
_FreeConsole dw 0
|
||||
db 'FreeConsole',0
|
||||
|
||||
align 2
|
||||
_GetStdHandle dw 0
|
||||
db 'GetStdHandle',0
|
||||
|
||||
align 2
|
||||
_AllocConsole dw 0
|
||||
db 'AllocConsole',0
|
||||
|
||||
align 2
|
||||
_CreateThread dw 0
|
||||
db 'CreateThread',0
|
||||
|
||||
align 2
|
||||
_Sleep dw 0
|
||||
db 'Sleep',0
|
||||
|
||||
align 2
|
||||
_AdjustWindowRect dw 0
|
||||
db 'AdjustWindowRect',0
|
||||
|
||||
align 2
|
||||
_MessageBeep dw 0
|
||||
db 'MessageBeep',0
|
||||
|
||||
align 2
|
||||
_TextOut dw 0
|
||||
db 'TextOutW',0
|
||||
|
||||
align 2
|
||||
_MoveToEx dw 0
|
||||
db 'MoveToEx',0
|
||||
|
||||
align 2
|
||||
_SetTextAlign dw 0
|
||||
db 'SetTextAlign',0
|
||||
|
||||
align 2
|
||||
_BitBlt dw 0
|
||||
db 'BitBlt',0
|
||||
|
||||
align 2
|
||||
_CreateCompatibleBitmap dw 0
|
||||
db 'CreateCompatibleBitmap',0
|
||||
|
||||
align 2
|
||||
_DeleteDC dw 0
|
||||
db 'DeleteDC',0
|
||||
|
||||
align 2
|
||||
_MulDiv dw 0
|
||||
db 'MulDiv',0
|
||||
|
||||
align 2
|
||||
_GetCursorPos dw 0
|
||||
db 'GetCursorPos',0
|
||||
|
||||
align 2
|
||||
_TrackPopupMenu dw 0
|
||||
db 'TrackPopupMenu',0
|
||||
|
||||
align 2
|
||||
_AppendMenu dw 0
|
||||
db 'AppendMenuW',0
|
||||
|
||||
align 2
|
||||
_DestroyMenu dw 0
|
||||
db 'DestroyMenu',0
|
||||
|
||||
align 2
|
||||
_CreatePopupMenu dw 0
|
||||
db 'CreatePopupMenu',0
|
||||
|
||||
align 2
|
||||
_GetFocus dw 0
|
||||
db 'GetFocus',0
|
||||
|
||||
align 2
|
||||
_SetTextColor dw 0
|
||||
db 'SetTextColor',0
|
||||
|
||||
align 2
|
||||
_GetWindowTextLen dw 0
|
||||
db 'GetWindowTextLengthW',0
|
||||
|
||||
align 2
|
||||
_GetWindowText dw 0
|
||||
db 'GetWindowTextW',0
|
||||
|
||||
align 2
|
||||
_CreatePatternBrush dw 0
|
||||
db 'CreatePatternBrush',0
|
||||
|
||||
align 2
|
||||
_GetDlgItem dw 0
|
||||
db 'GetDlgItem',0
|
||||
|
||||
align 2
|
||||
_VirtualFree dw 0
|
||||
db 'VirtualFree',0
|
||||
|
||||
align 2
|
||||
_VirtualAlloc dw 0
|
||||
db 'VirtualAlloc',0
|
||||
|
||||
align 2
|
||||
_ImageList_AddMasked dw 0
|
||||
db 'ImageList_AddMasked',0
|
||||
|
||||
align 2
|
||||
_ImageList_Create dw 0
|
||||
db 'ImageList_Create',0
|
||||
|
||||
align 2
|
||||
_PostMessage dw 0
|
||||
db 'PostMessageW',0
|
||||
|
||||
align 2
|
||||
_SendMessage dw 0
|
||||
db 'SendMessageW',0
|
||||
|
||||
align 2
|
||||
_GetFileSize dw 0
|
||||
db 'GetFileSize',0
|
||||
|
||||
align 2
|
||||
_WriteFile dw 0
|
||||
db 'WriteFile',0
|
||||
|
||||
align 2
|
||||
_ReadFile dw 0
|
||||
db 'ReadFile',0
|
||||
|
||||
align 2
|
||||
_CloseHandle dw 0
|
||||
db 'CloseHandle',0
|
||||
|
||||
align 2
|
||||
_CreateFile dw 0
|
||||
db 'CreateFileW',0
|
||||
|
||||
align 2
|
||||
_CreateFileAnsi dw 0
|
||||
db 'CreateFileA',0
|
||||
|
||||
align 2
|
||||
_InflateRect dw 0
|
||||
db 'InflateRect',0
|
||||
|
||||
align 2
|
||||
_EndDialog dw 0
|
||||
db 'EndDialog',0
|
||||
|
||||
align 2
|
||||
_DlgBoxParam dw 0
|
||||
db 'DialogBoxIndirectParamW',0
|
||||
|
||||
align 2
|
||||
_GetSystemMetrics dw 0
|
||||
db 'GetSystemMetrics',0
|
||||
|
||||
align 2
|
||||
_GetStockObject dw 0
|
||||
db 'GetStockObject',0
|
||||
|
||||
align 2
|
||||
_GetTickCount dw 0
|
||||
db 'GetTickCount',0
|
||||
|
||||
align 2
|
||||
_FindClose dw 0
|
||||
db 'FindClose',0
|
||||
|
||||
align 2
|
||||
_FindNextFile dw 0
|
||||
db 'FindNextFileW',0
|
||||
|
||||
align 2
|
||||
_FindFirstFile dw 0
|
||||
db 'FindFirstFileW',0
|
||||
|
||||
align 2
|
||||
_DrawText dw 0
|
||||
db 'DrawTextW',0
|
||||
|
||||
align 2
|
||||
_DrawIcon dw 0
|
||||
db 'DrawIcon',0
|
||||
|
||||
align 2
|
||||
_CreatePen dw 0
|
||||
db 'CreatePen',0
|
||||
|
||||
align 2
|
||||
_Polyline dw 0
|
||||
db 'Polyline',0
|
||||
|
||||
align 2
|
||||
_CreateSolidBrush dw 0
|
||||
db 'CreateSolidBrush',0
|
||||
|
||||
align 2
|
||||
_DeleteObject dw 0
|
||||
db 'DeleteObject',0
|
||||
|
||||
align 2
|
||||
_SetCapture dw 0
|
||||
db 'SetCapture',0
|
||||
|
||||
align 2
|
||||
_ReleaseCapture dw 0
|
||||
db 'ReleaseCapture',0
|
||||
|
||||
align 2
|
||||
_SetWindowText dw 0
|
||||
db 'SetWindowTextW',0
|
||||
|
||||
align 2
|
||||
_InitCommonControlsEx dw 0
|
||||
db 'InitCommonControlsEx',0
|
||||
|
||||
align 2
|
||||
_SetCursor dw 0
|
||||
db 'SetCursor',0
|
||||
|
||||
align 2
|
||||
_GetProcessHeap dw 0
|
||||
db 'GetProcessHeap',0
|
||||
|
||||
align 2
|
||||
_CreateFontIndirect dw 0
|
||||
db 'CreateFontIndirectW',0
|
||||
|
||||
align 2
|
||||
_GetDeviceCaps dw 0
|
||||
db 'GetDeviceCaps',0
|
||||
|
||||
align 2
|
||||
_ReleaseDC dw 0
|
||||
db 'ReleaseDC',0
|
||||
|
||||
align 2
|
||||
_GetDC dw 0
|
||||
db 'GetDC',0
|
||||
|
||||
align 2
|
||||
_GetTextExtentPoint32 dw 0
|
||||
db 'GetTextExtentPoint32W',0
|
||||
|
||||
align 2
|
||||
_GetModuleFileName dw 0
|
||||
db 'GetModuleFileNameW',0
|
||||
|
||||
align 2
|
||||
_FrameRect dw 0
|
||||
db 'FrameRect',0
|
||||
|
||||
align 2
|
||||
_FillRect dw 0
|
||||
db 'FillRect',0
|
||||
|
||||
align 2
|
||||
_SetBkMode dw 0
|
||||
db 'SetBkMode',0
|
||||
|
||||
align 2
|
||||
_EndPaint dw 0
|
||||
db 'EndPaint',0
|
||||
|
||||
align 2
|
||||
_BeginPaint dw 0
|
||||
db 'BeginPaint',0
|
||||
|
||||
align 2
|
||||
_SelectObject dw 0
|
||||
db 'SelectObject',0
|
||||
|
||||
align 2
|
||||
_OutputDebugString dw 0
|
||||
db 'OutputDebugStringW',0
|
||||
|
||||
align 2
|
||||
_HeapCreate dw 0
|
||||
db 'HeapCreate',0
|
||||
|
||||
align 2
|
||||
_HeapAlloc dw 0
|
||||
db 'HeapAlloc',0
|
||||
|
||||
align 2
|
||||
_HeapReAlloc dw 0
|
||||
db 'HeapReAlloc',0
|
||||
|
||||
align 2
|
||||
_HeapFree dw 0
|
||||
db 'HeapFree',0
|
||||
|
||||
align 2
|
||||
_HeapDestroy dw 0
|
||||
db 'HeapDestroy',0
|
||||
|
||||
align 2
|
||||
_IsWindowVisible dw 0
|
||||
db 'IsWindowVisible',0
|
||||
|
||||
align 2
|
||||
_MoveWindow dw 0
|
||||
db 'MoveWindow',0
|
||||
|
||||
align 2
|
||||
_InvalidateRect dw 0
|
||||
db 'InvalidateRect',0
|
||||
|
||||
align 2
|
||||
_UpdateWindow dw 0
|
||||
db 'UpdateWindow',0
|
||||
|
||||
align 2
|
||||
_CreateAcceleratorTable dw 0
|
||||
db 'CreateAcceleratorTableW',0
|
||||
|
||||
align 2
|
||||
_TranslateAccelerator dw 0
|
||||
db 'TranslateAccelerator',0
|
||||
|
||||
align 2
|
||||
_TranslateMessage dw 0
|
||||
db 'TranslateMessage',0
|
||||
|
||||
align 2
|
||||
_DispatchMessage dw 0
|
||||
db 'DispatchMessageW',0
|
||||
|
||||
align 2
|
||||
_GetMessage dw 0
|
||||
db 'GetMessageW',0
|
||||
|
||||
align 2
|
||||
_PostQuitMessage dw 0
|
||||
db 'PostQuitMessage',0
|
||||
|
||||
align 2
|
||||
_LoadBitmap dw 0
|
||||
db 'LoadBitmapW',0
|
||||
|
||||
align 2
|
||||
_LoadImage dw 0
|
||||
db 'LoadImageW',0
|
||||
|
||||
align 2
|
||||
_LoadIcon dw 0
|
||||
db 'LoadIconW',0
|
||||
|
||||
align 2
|
||||
_LoadCursor dw 0
|
||||
db 'LoadCursorW',0
|
||||
|
||||
align 2
|
||||
_GetWindowRect dw 0
|
||||
db 'GetWindowRect',0
|
||||
|
||||
align 2
|
||||
_GetClientRect dw 0
|
||||
db 'GetClientRect',0
|
||||
|
||||
align 2
|
||||
_ShowWindow dw 0
|
||||
db 'ShowWindow',0
|
||||
|
||||
align 2
|
||||
_CreateWindowEx dw 0
|
||||
db 'CreateWindowExW',0
|
||||
|
||||
align 2
|
||||
_DefWindowProc dw 0
|
||||
db 'DefWindowProcW',0
|
||||
|
||||
align 2
|
||||
_RegisterClass dw 0
|
||||
db 'RegisterClassW',0
|
||||
|
||||
align 2
|
||||
_GetClassInfo dw 0
|
||||
db 'GetClassInfoW',0
|
||||
|
||||
align 2
|
||||
_SetWindowLong dw 0
|
||||
db 'SetWindowLongW',0
|
||||
|
||||
align 2
|
||||
_GetWindowLong dw 0
|
||||
db 'GetWindowLongW',0
|
||||
|
||||
align 2
|
||||
_GetModuleHandle dw 0
|
||||
db 'GetModuleHandleW',0
|
||||
|
||||
align 2
|
||||
_CreateCompatibleDC dw 0
|
||||
db 'CreateCompatibleDC',0
|
||||
|
||||
align 2
|
||||
_ExitProcess dw 0
|
||||
db 'ExitProcess',0
|
||||
|
||||
align 2
|
||||
_MessageBox dw 0
|
||||
db 'MessageBoxW',0
|
||||
|
||||
;<EOF>
|
98
programs/games/StarTrek/trunk/MAIN.ASM
Normal file
98
programs/games/StarTrek/trunk/MAIN.ASM
Normal file
@ -0,0 +1,98 @@
|
||||
; --------------------------------------------------------------------------
|
||||
; Win32 PE File Template
|
||||
; {BINEXT=EXE} (Do not edit or remove this line)
|
||||
; --------------------------------------------------------------------------
|
||||
|
||||
; *********************************************************************
|
||||
; * PERMISSION IS HEREBY GRANTED FOR THE COPYING, *
|
||||
; * DISTRIBUTION, MODIFICATION AND USE OF THIS PROGRAM AND *
|
||||
; * ASSOCIATED DOCUMENTATION FOR RECREATIONAL PURPOSES, *
|
||||
; * PROVIDED THAT ALL REFERENCES TO THE AUTHOR ARE RETAINED. *
|
||||
; * HOWEVER, PERMISSION IS NOT AND WILL NOT BE GRANTED FOR *
|
||||
; * THE SALE OR PROMOTIONAL USE OF THIS PROGRAM OR PROGRAM *
|
||||
; * DOCUMENTATION, OR FOR USE IN ANY SITUATION IN WHICH *
|
||||
; * PROFIT MAY BE CONSIDERED AN OBJECTIVE, SINCE IT IS THE *
|
||||
; * DESIRE OF THE AUTHOR TO RESPECT THE COPYRIGHTS OF THE *
|
||||
; * ORIGINATORS OF STAR TREK. *
|
||||
; *********************************************************************
|
||||
|
||||
format PE GUI 4.0
|
||||
entry start
|
||||
stack 10000h, 10000h
|
||||
|
||||
; --------------------------------------------------------------------------
|
||||
; Definitions
|
||||
; --------------------------------------------------------------------------
|
||||
|
||||
include 'Macros.Inc'
|
||||
include 'Win32.Inc'
|
||||
include 'TConsole.Inc'
|
||||
include 'TCmdBuf.Inc'
|
||||
include 'TCommon.Inc'
|
||||
include 'TRandom.Inc'
|
||||
include 'TLog.Inc'
|
||||
;{INCLDEF} (Definitions will be inserted before this line)
|
||||
|
||||
PROC_ALIGN equ 8
|
||||
|
||||
; --------------------------------------------------------------------------
|
||||
; Data Section
|
||||
; --------------------------------------------------------------------------
|
||||
section '.data' data readable writeable
|
||||
|
||||
include 'Globals.Inc'
|
||||
|
||||
; --------------------------------------------------------------------------
|
||||
; Code Modules
|
||||
; --------------------------------------------------------------------------
|
||||
section '.code' code readable executable
|
||||
|
||||
include 'TApp.Asm'
|
||||
include 'TConsole.Asm'
|
||||
include 'TString.Asm'
|
||||
include 'TCmdBuf.Asm'
|
||||
include 'TGame.Asm'
|
||||
include 'TMsgTable.Asm'
|
||||
include 'TCommon.Asm'
|
||||
include 'TRandom.Asm'
|
||||
include 'TArray.Asm'
|
||||
include 'TFormat.Asm'
|
||||
include 'TSrScan.Asm'
|
||||
include 'TLrScan.Asm'
|
||||
include 'TChart.Asm'
|
||||
include 'TMove.Asm'
|
||||
include 'TFinish.Asm'
|
||||
include 'TAttack.Asm'
|
||||
include 'TEvents.Asm'
|
||||
include 'TNova.Asm'
|
||||
include 'TPhasers.Asm'
|
||||
include 'TShields.Asm'
|
||||
include 'TDock.Asm'
|
||||
include 'TPhotons.Asm'
|
||||
include 'TPlanet.Asm'
|
||||
include 'TImpulse.Asm'
|
||||
include 'TLog.Asm'
|
||||
;{INCLIMPL} (Code modules will be inserted before this line)
|
||||
|
||||
; --------------------------------------------------------------------------
|
||||
; Entry Point
|
||||
; --------------------------------------------------------------------------
|
||||
align PROC_ALIGN
|
||||
start:
|
||||
call TApp_SetLocalDir
|
||||
jnc .exit
|
||||
|
||||
call TApp_Init
|
||||
call TApp_Run
|
||||
|
||||
.exit:
|
||||
invoke ExitProcess, 0
|
||||
|
||||
; --------------------------------------------------------------------------
|
||||
; Imports
|
||||
; --------------------------------------------------------------------------
|
||||
section '.idata' import data readable writeable
|
||||
|
||||
include 'Imports.Inc'
|
||||
|
||||
; --- EOF ---
|
292
programs/games/StarTrek/trunk/Macros.Inc
Normal file
292
programs/games/StarTrek/trunk/Macros.Inc
Normal file
@ -0,0 +1,292 @@
|
||||
|
||||
_DEBUG = 1
|
||||
|
||||
; --- Parameters inside WndProc
|
||||
|
||||
hWnd equ [ebp + 8]
|
||||
uiMsg equ [ebp + 12]
|
||||
WParam equ [ebp + 16]
|
||||
LParam equ [ebp + 20]
|
||||
|
||||
; --- Splitting WndProc parameters
|
||||
|
||||
macro mcLPtoXY LParam {
|
||||
; OUT: EDX = Y coordinate or HEIGHT
|
||||
; OUT: EAX = X coordinate or WIDTH
|
||||
mov eax, LParam
|
||||
mov edx, LParam
|
||||
and eax, 0000FFFFh
|
||||
shr edx, 16
|
||||
}
|
||||
|
||||
; --- String operation (WCHAR)
|
||||
|
||||
macro mcStrCopy {
|
||||
xor eax, eax
|
||||
@@:
|
||||
lodsw
|
||||
stosw
|
||||
test eax, eax
|
||||
jnz @r
|
||||
}
|
||||
|
||||
; --- Indirectly call STDCALL procedure
|
||||
|
||||
macro invoke api_proc, [arg]
|
||||
{
|
||||
common
|
||||
if ~ arg eq
|
||||
reverse
|
||||
pushd arg
|
||||
common
|
||||
end if
|
||||
call [api_proc]
|
||||
}
|
||||
|
||||
macro rinvoke api_proc_reg, [arg]
|
||||
{
|
||||
common
|
||||
if ~ arg eq
|
||||
reverse
|
||||
pushd arg
|
||||
common
|
||||
end if
|
||||
call api_proc_reg
|
||||
}
|
||||
|
||||
; --- FPU
|
||||
|
||||
macro mcFpuPushR32 r32
|
||||
{
|
||||
mov [glb_FPU_Int32], r32
|
||||
fild [glb_FPU_Int32]
|
||||
}
|
||||
|
||||
macro mcFpuPop
|
||||
{
|
||||
fstp [glb_dbl_FpuPopper]
|
||||
}
|
||||
|
||||
; --- Heap allocator
|
||||
|
||||
macro mcMemAlloc hHeap, nBytes {
|
||||
invoke HeapAlloc, hHeap, HEAP_NO_SERIALIZE, nBytes
|
||||
}
|
||||
|
||||
macro mcMemFree hHeap, pBuf {
|
||||
invoke HeapFree, hHeap, HEAP_NO_SERIALIZE, pBuf
|
||||
}
|
||||
|
||||
macro mcGlobalMalloc nBytes {
|
||||
mcMemAlloc [glb_HAllocator], nBytes
|
||||
}
|
||||
|
||||
macro mcGlobalFree pBuf {
|
||||
mcMemFree [glb_HAllocator], pBuf
|
||||
}
|
||||
|
||||
; --- Page allocator
|
||||
|
||||
macro mcAllocatePages nBytes {
|
||||
invoke VirtualAlloc, 0, nBytes, \
|
||||
MEM_RESERVE or MEM_COMMIT, \
|
||||
PAGE_READWRITE
|
||||
}
|
||||
|
||||
macro mcReleasePages pData {
|
||||
invoke VirtualFree, pData, 0, MEM_RELEASE
|
||||
}
|
||||
|
||||
; --- Local variables
|
||||
|
||||
macro mcLoadLocalRef AnyReg, instance {
|
||||
lea AnyReg, [esp + instance]
|
||||
}
|
||||
|
||||
macro mcLoadLocal AnyReg, instance {
|
||||
mov AnyReg, [esp + instance]
|
||||
}
|
||||
|
||||
macro mcStoreThis {
|
||||
mov [esp], ebx
|
||||
}
|
||||
|
||||
macro mcLoadThis {
|
||||
mov ebx, [esp]
|
||||
}
|
||||
|
||||
macro mcStoreLocal instance, AnyReg {
|
||||
mov [esp + instance], AnyReg
|
||||
}
|
||||
|
||||
macro mcBeginLocals LocalSize {
|
||||
sub esp, LocalSize
|
||||
}
|
||||
|
||||
macro mcEndLocals LocalSize {
|
||||
add esp, LocalSize
|
||||
}
|
||||
|
||||
; --- Virtual call on the object instance
|
||||
|
||||
macro mcVirtCallOnEBX OfsMethod {
|
||||
mov eax, [ebx]
|
||||
call dword [eax + OfsMethod]
|
||||
}
|
||||
|
||||
macro mcVirtCall Instance, OfsMethod {
|
||||
lea ebx, [Instance]
|
||||
mov eax, [ebx]
|
||||
call dword [eax + OfsMethod]
|
||||
}
|
||||
|
||||
; --- CALLBACK
|
||||
|
||||
macro mcProlog {
|
||||
push ebp
|
||||
mov ebp, esp
|
||||
push ebx
|
||||
push esi
|
||||
push edi
|
||||
}
|
||||
|
||||
macro mcEpilog {
|
||||
pop edi
|
||||
pop esi
|
||||
pop ebx
|
||||
leave
|
||||
}
|
||||
|
||||
; --- Misc...
|
||||
|
||||
macro mc_CMP_ST0_ST1
|
||||
{
|
||||
fcomip st, st1
|
||||
fstp [glb_dbl_FpuPopper]
|
||||
}
|
||||
|
||||
macro mcLoadQuadStatePtr r32
|
||||
{
|
||||
mov r32, [glb_pGameState]
|
||||
add r32, TGameState.game_QuadState
|
||||
}
|
||||
|
||||
macro mcLoadNeg1 r32
|
||||
{
|
||||
mcZeroBits r32
|
||||
dec r32
|
||||
}
|
||||
|
||||
macro mcLoad8bitsToReg32 r32, _8bit_value
|
||||
{
|
||||
push _8bit_value
|
||||
pop r32
|
||||
}
|
||||
|
||||
macro mcLoad1 r32
|
||||
{
|
||||
mcZeroBits r32
|
||||
inc r32
|
||||
}
|
||||
|
||||
; ESI = source
|
||||
; EDI = destination
|
||||
macro mcMemCopy nBytesAligned4
|
||||
{
|
||||
mov ecx, nBytesAligned4
|
||||
shr ecx, 2
|
||||
rep movsd
|
||||
}
|
||||
|
||||
macro mcMul10 r32 {
|
||||
push esi
|
||||
shl r32, 1
|
||||
push r32
|
||||
shl r32, 2
|
||||
pop esi
|
||||
add r32, esi
|
||||
pop esi
|
||||
}
|
||||
|
||||
macro mcZeroBits any_reg {
|
||||
xor any_reg, any_reg
|
||||
}
|
||||
|
||||
macro mcLoadRGB reg32, r8, g8, b8 {
|
||||
mov reg32, (b8 shl 16) or (g8 shl 8) or r8
|
||||
}
|
||||
|
||||
; --- Rectangle
|
||||
|
||||
macro mcRectCopy {
|
||||
; ESI = source rectangle
|
||||
; EDI = target rectangle
|
||||
movsd
|
||||
movsd
|
||||
movsd
|
||||
movsd
|
||||
}
|
||||
|
||||
macro mcRectCopySafe {
|
||||
; ESI = source rectangle
|
||||
; EDI = target rectangle
|
||||
push esi
|
||||
movsd
|
||||
movsd
|
||||
movsd
|
||||
movsd
|
||||
pop esi
|
||||
}
|
||||
|
||||
macro mcRectWidth r32, pRect {
|
||||
mov r32, [pRect + RECT.rc_Right]
|
||||
sub r32, [pRect + RECT.rc_Left]
|
||||
}
|
||||
|
||||
macro mcRectHeight r32, pRect {
|
||||
mov r32, [pRect + RECT.rc_Bottom]
|
||||
sub r32, [pRect + RECT.rc_Top]
|
||||
}
|
||||
|
||||
; --- Branching
|
||||
|
||||
macro mcOnRegEqu AnyReg, AnyValue, AnyLabel {
|
||||
cmp AnyReg, AnyValue
|
||||
je AnyLabel
|
||||
}
|
||||
|
||||
macro mcOnRegNotEqu AnyReg, AnyValue, AnyLabel {
|
||||
cmp AnyReg, AnyValue
|
||||
jne AnyLabel
|
||||
}
|
||||
|
||||
macro mcOnRegZero AnyReg, AnyLabel {
|
||||
test AnyReg, AnyReg
|
||||
jz AnyLabel
|
||||
}
|
||||
|
||||
macro mcOnRegNotZero AnyReg, AnyLabel {
|
||||
test AnyReg, AnyReg
|
||||
jnz AnyLabel
|
||||
}
|
||||
|
||||
; --- OOP
|
||||
|
||||
macro mcLoadMemberRef AnyReg, instance {
|
||||
lea AnyReg, [ebx + instance]
|
||||
}
|
||||
|
||||
macro mcLoadMember AnyReg, instance {
|
||||
mov AnyReg, [ebx + instance]
|
||||
}
|
||||
|
||||
macro mcStoreMember instance, AnyReg {
|
||||
mov [ebx + instance], AnyReg
|
||||
}
|
||||
|
||||
macro mcAttachVTable addrvtbl {
|
||||
mov eax, addrvtbl
|
||||
mov [ebx], eax
|
||||
}
|
||||
|
||||
; --- EOF ---
|
770
programs/games/StarTrek/trunk/TApp.Asm
Normal file
770
programs/games/StarTrek/trunk/TApp.Asm
Normal file
@ -0,0 +1,770 @@
|
||||
; --------------------------------------------------------------------------
|
||||
; FILE: TApp.Asm
|
||||
; DATE: September 21, 2008
|
||||
; --------------------------------------------------------------------------
|
||||
|
||||
; --------------------------------------------------------------------------
|
||||
; DESTRCT
|
||||
; --------------------------------------------------------------------------
|
||||
virtual at 0
|
||||
loc84:
|
||||
.nCountDown COUNT ?
|
||||
.size = $
|
||||
end virtual
|
||||
; --------------------------------------------------------------------------
|
||||
align PROC_ALIGN
|
||||
TApp_SelfDestruct:
|
||||
mcBeginLocals loc84.size
|
||||
|
||||
mov cl, DEV_COMPUTER
|
||||
call TArray_IsDamaged
|
||||
jnc .L5
|
||||
|
||||
call TConsole_ScrollUp
|
||||
mov ecx, 686
|
||||
call TConsole_ProutGameMsg
|
||||
call TConsole_ScrollUp
|
||||
jmp .done
|
||||
|
||||
.L5:
|
||||
call TConsole_ScrollUp
|
||||
mov ecx, 290
|
||||
call TConsole_ProutGameMsg
|
||||
mov ecx, 687
|
||||
call TConsole_Prout
|
||||
inc ecx
|
||||
call TConsole_Prout
|
||||
call TConsole_ScrollUp
|
||||
|
||||
mcLoad8bitsToReg32 ecx, 10
|
||||
mcStoreLocal loc84.nCountDown, ecx
|
||||
|
||||
.pre_sequence:
|
||||
mov ecx, 694
|
||||
call TConsole_Cram
|
||||
mcLoadLocal eax, loc84.nCountDown
|
||||
call TConsole_CramInt
|
||||
call TConsole_RefreshCaretLine
|
||||
invoke Sleep, 1000
|
||||
|
||||
dec [esp + loc84.nCountDown]
|
||||
cmp [esp + loc84.nCountDown], 6
|
||||
jae .pre_sequence
|
||||
|
||||
call TConsole_ScrollUp
|
||||
call TConsole_ScrollUp
|
||||
|
||||
mov cl, ATTR_PROMPT_TEXT
|
||||
call TConsole_SetAttr
|
||||
|
||||
mov ecx, 689
|
||||
call TConsole_Prout
|
||||
inc ecx
|
||||
call TConsole_Prout
|
||||
inc ecx
|
||||
call TGame_Prompt
|
||||
call TConsole_ScrollUp
|
||||
|
||||
call TCmdBuf_Scan
|
||||
cmp [ebx + TCmdBuf.cmdbuf_KEY], CMD_TOKEN_EOL
|
||||
je .password_rejected
|
||||
|
||||
mcLoadGameDataPtr edi
|
||||
add edi, TREKDATA.PASSWD
|
||||
call TString_AnsiEqual
|
||||
jnc .password_rejected
|
||||
|
||||
mov ecx, 692
|
||||
call TConsole_ProutGameMsg
|
||||
mov cl, 22
|
||||
call TConsole_RepeatBlank
|
||||
|
||||
.final_sequence:
|
||||
mov ecx, 694
|
||||
call TConsole_Cram
|
||||
mcLoadLocal eax, loc84.nCountDown
|
||||
call TConsole_CramInt
|
||||
call TConsole_RefreshCaretLine
|
||||
invoke Sleep, 1000
|
||||
|
||||
dec [esp + loc84.nCountDown]
|
||||
jnz .final_sequence
|
||||
|
||||
call TConsole_ScrollUp
|
||||
|
||||
fld [glb_dbl_0dot05]
|
||||
call TRandom_Ranf
|
||||
mc_CMP_ST0_ST1
|
||||
jnc .everyone_wasted
|
||||
|
||||
mov ecx, 693
|
||||
call TConsole_ProutGameMsg
|
||||
invoke Sleep, 1000
|
||||
|
||||
.everyone_wasted:
|
||||
call TConsole_ScrollUp
|
||||
call TConsole_ScrollUp
|
||||
call TPlanet_KaBoom
|
||||
jmp .done
|
||||
|
||||
.password_rejected:
|
||||
mov ecx, 695
|
||||
call TConsole_ProutGameMsg
|
||||
inc ecx
|
||||
call TConsole_Prout
|
||||
call TConsole_ScrollUp
|
||||
call TConsole_ScrollUp
|
||||
|
||||
.done:
|
||||
mcEndLocals loc84.size
|
||||
ret
|
||||
|
||||
; --------------------------------------------------------------------------
|
||||
; PLAQUE
|
||||
; --------------------------------------------------------------------------
|
||||
virtual at 0
|
||||
loc112:
|
||||
.pNextInByte PCHAR ?
|
||||
.pNextOutByte PCHAR ?
|
||||
.bufAnsiValue CHARS 16
|
||||
.bufAnsiKirkAlias CHARS 32
|
||||
.pAllocatedOutBuffer PCHAR ?
|
||||
.timeNow rb SYSTIME.size
|
||||
.nLenName COUNT ?
|
||||
.size = $
|
||||
end virtual
|
||||
; --------------------------------------------------------------------------
|
||||
align PROC_ALIGN
|
||||
TApp_PlaqueProcessor:
|
||||
mcBeginLocals loc112.size
|
||||
|
||||
mov ecx, 727
|
||||
call TGame_Prompt
|
||||
|
||||
call TCmdBuf_Scan
|
||||
cmp [ebx + TCmdBuf.cmdbuf_KEY], CMD_TOKEN_EOL
|
||||
je .done
|
||||
|
||||
mcLoadLocalRef edi, loc112.bufAnsiKirkAlias
|
||||
call TString_AnsiCopy
|
||||
|
||||
mov esi, glb_Plaque
|
||||
invoke HeapAlloc, [glb_Allocator], HEAP_NO_SERIALIZE, 8192 ; <-- 2 pages is enough!
|
||||
mcStoreLocal loc112.pAllocatedOutBuffer, eax
|
||||
mcStoreLocal loc112.pNextOutByte, eax
|
||||
mcStoreLocal loc112.pNextInByte, esi
|
||||
|
||||
.load_input_byte:
|
||||
mcLoadLocal esi, loc112.pNextInByte
|
||||
inc [esp + loc112.pNextInByte]
|
||||
mov al, [esi]
|
||||
|
||||
mcOnRegEqu al, PLAQUE_STRING, .dump_string
|
||||
mcOnRegEqu al, PLAQUE_INSERT_DATE, .dump_date
|
||||
mcOnRegEqu al, PLAQUE_INSERT_KLRATE, .dump_klrate
|
||||
mcOnRegEqu al, PLAQUE_INSERT_LEVEL, .dump_level
|
||||
mcOnRegEqu al, PLAQUE_INSERT_NAME, .dump_captain_name
|
||||
mcOnRegEqu al, PLAQUE_INSERT_SCORE, .dump_score
|
||||
mcOnRegEqu al, PLAQUE_END_OF_LINE, .dump_CR_LF
|
||||
mcOnRegEqu al, PLAQUE_END_OF_ALL, .save
|
||||
;
|
||||
; This byte is a count of charactes defined by next byte
|
||||
;
|
||||
movzx ecx, al
|
||||
mov al, [esi + 1]
|
||||
inc [esp + loc112.pNextInByte]
|
||||
mcLoadLocal edi, loc112.pNextOutByte
|
||||
add [esp + loc112.pNextOutByte], ecx
|
||||
rep stosb
|
||||
jmp .load_input_byte
|
||||
|
||||
.dump_string:
|
||||
;
|
||||
; The next byte is a length of data to be copied
|
||||
;
|
||||
movzx ecx, byte [esi + 1]
|
||||
inc [esp + loc112.pNextInByte]
|
||||
;
|
||||
; Copy data
|
||||
;
|
||||
mcLoadLocal edi, loc112.pNextOutByte
|
||||
mcLoadLocal esi, loc112.pNextInByte
|
||||
add [esp + loc112.pNextInByte], ecx
|
||||
add [esp + loc112.pNextOutByte], ecx
|
||||
rep movsb
|
||||
jmp .load_input_byte
|
||||
|
||||
.dump_date:
|
||||
mcLoadLocalRef edi, loc112.timeNow
|
||||
invoke GetLocalTime, edi
|
||||
|
||||
movzx ecx, word [edi + SYSTIME.wMonth]
|
||||
add ecx, 714
|
||||
call TMsgTable_GetItem
|
||||
|
||||
call TCmdBuf_AnsiStrLen
|
||||
mcLoadLocal edi, loc112.pNextOutByte
|
||||
add [esp + loc112.pNextOutByte], ecx
|
||||
rep movsb
|
||||
|
||||
mov al, ' '
|
||||
stosb
|
||||
inc [esp + loc112.pNextOutByte]
|
||||
|
||||
mcLoadLocalRef esi, loc112.timeNow
|
||||
movzx eax, word [esi + SYSTIME.wDay]
|
||||
mcLoadLocalRef edi, loc112.bufAnsiValue
|
||||
call TFormat_Int32
|
||||
|
||||
mov esi, edi
|
||||
mcLoadLocal edi, loc112.pNextOutByte
|
||||
add [esp + loc112.pNextOutByte], ecx
|
||||
rep movsb
|
||||
|
||||
mov al, ','
|
||||
stosb
|
||||
mov al, ' '
|
||||
stosb
|
||||
add [esp + loc112.pNextOutByte], 2
|
||||
|
||||
mcLoadLocalRef esi, loc112.timeNow
|
||||
movzx eax, word [esi + SYSTIME.wYear]
|
||||
mcLoadLocalRef edi, loc112.bufAnsiValue
|
||||
call TFormat_Int32
|
||||
|
||||
mov esi, edi
|
||||
mcLoadLocal edi, loc112.pNextOutByte
|
||||
add [esp + loc112.pNextOutByte], ecx
|
||||
rep movsb
|
||||
jmp .load_input_byte
|
||||
|
||||
.dump_klrate:
|
||||
mov cl, 2
|
||||
mcLoadLocalRef edi, loc112.bufAnsiValue
|
||||
fld [glb_dbl_KlingonsPerDate]
|
||||
call TFormat_Double
|
||||
|
||||
mov esi, edi
|
||||
mcLoadLocal edi, loc112.pNextOutByte
|
||||
add [esp + loc112.pNextOutByte], ecx
|
||||
rep movsb
|
||||
jmp .load_input_byte
|
||||
|
||||
.dump_level:
|
||||
mcLoadGameDataPtr esi
|
||||
movzx ecx, [esi + TREKDATA.SKILL]
|
||||
add cl, 12
|
||||
call TMsgTable_GetItem
|
||||
|
||||
mcLoadLocal edi, loc112.pNextOutByte
|
||||
mcZeroBits eax
|
||||
mcZeroBits ecx
|
||||
|
||||
.next_level_char:
|
||||
lodsb
|
||||
mcOnRegZero eax, .level_copied
|
||||
|
||||
stosb
|
||||
inc ecx
|
||||
jmp .next_level_char
|
||||
|
||||
.level_copied:
|
||||
add [esp + loc112.pNextOutByte], ecx
|
||||
jmp .load_input_byte
|
||||
|
||||
.dump_captain_name:
|
||||
;
|
||||
; NSKIP = 65 - LEN (NAME)/2
|
||||
;
|
||||
mcLoadLocalRef esi, loc112.bufAnsiKirkAlias
|
||||
call TCmdBuf_AnsiStrLen
|
||||
mcStoreLocal loc112.nLenName, ecx
|
||||
mcLoad8bitsToReg32 eax, 65
|
||||
shr ecx, 1
|
||||
sub eax, ecx
|
||||
|
||||
mov cl, ' '
|
||||
xchg eax, ecx
|
||||
mcLoadLocal edi, loc112.pNextOutByte
|
||||
add [esp + loc112.pNextOutByte], ecx
|
||||
rep stosb
|
||||
|
||||
mcLoadLocalRef esi, loc112.bufAnsiKirkAlias
|
||||
mcLoadLocal ecx, loc112.nLenName
|
||||
add [esp + loc112.pNextOutByte], ecx
|
||||
rep movsb
|
||||
jmp .dump_CR_LF
|
||||
|
||||
.dump_score:
|
||||
mcLoadLocalRef edi, loc112.bufAnsiValue
|
||||
mov eax, [glb_Score]
|
||||
call TFormat_Int32
|
||||
|
||||
mov esi, edi
|
||||
mcLoadLocal edi, loc112.pNextOutByte
|
||||
add [esp + loc112.pNextOutByte], ecx
|
||||
rep movsb
|
||||
jmp .load_input_byte
|
||||
|
||||
.dump_CR_LF:
|
||||
mcLoadLocal edi, loc112.pNextOutByte
|
||||
mov al, 0Dh
|
||||
stosb
|
||||
mov al, 0Ah
|
||||
stosb
|
||||
mcStoreLocal loc112.pNextOutByte, edi
|
||||
jmp .load_input_byte
|
||||
|
||||
.save:
|
||||
invoke CreateFileAnsi, str_PlaqueFile, GENERIC_WRITE, 0, 0,\
|
||||
CREATE_ALWAYS, FILE_FLAG_SEQ_SCAN, 0
|
||||
|
||||
mov ebx, eax
|
||||
mcOnRegEqu ebx, -1, .done
|
||||
|
||||
mcLoadLocal esi, loc112.pAllocatedOutBuffer
|
||||
mcLoadLocalRef edi, loc112.pNextInByte
|
||||
mcLoadLocal ecx, loc112.pNextOutByte
|
||||
sub ecx, esi
|
||||
invoke WriteFile, ebx, esi, ecx, edi, 0
|
||||
invoke CloseHandle, ebx
|
||||
|
||||
call TConsole_SetGameMsgAttr
|
||||
mov cl, 3
|
||||
call TConsole_Skip
|
||||
|
||||
mov ecx, 728
|
||||
call TConsole_Prout
|
||||
inc ecx
|
||||
call TConsole_Prout
|
||||
inc ecx
|
||||
call TConsole_Prout
|
||||
|
||||
mov cl, 3
|
||||
call TConsole_Skip
|
||||
|
||||
.done:
|
||||
mcEndLocals loc112.size
|
||||
ret
|
||||
|
||||
; --------------------------------------------------------------------------
|
||||
; Output:
|
||||
; CF = TRUE if directory has been set
|
||||
; --------------------------------------------------------------------------
|
||||
align PROC_ALIGN
|
||||
TApp_SetLocalDir:
|
||||
mcBeginLocals 260*2
|
||||
|
||||
mov esi, esp
|
||||
invoke GetModuleFileName, 0, esi, 260
|
||||
|
||||
mcZeroBits eax
|
||||
mcZeroBits edi
|
||||
|
||||
.next_char:
|
||||
lodsw
|
||||
mcOnRegZero eax, .set_dir
|
||||
|
||||
cmp al, '\'
|
||||
jne .next_char
|
||||
|
||||
mov edi, esi
|
||||
jmp .next_char
|
||||
|
||||
.set_dir:
|
||||
mcOnRegZero edi, .failed
|
||||
|
||||
stosw
|
||||
invoke SetCurrentDir, esp
|
||||
mcOnRegZero eax, .failed
|
||||
|
||||
.done:
|
||||
mcEndLocals 260*2
|
||||
stc
|
||||
ret
|
||||
|
||||
.failed:
|
||||
invoke MessageBox, 0, str_SetDirFailed, str_MainWndTitle, 10h
|
||||
mcEndLocals 260*2
|
||||
ret
|
||||
|
||||
; --------------------------------------------------------------------------
|
||||
; Input:
|
||||
; EAX = HDC
|
||||
; --------------------------------------------------------------------------
|
||||
virtual at 0
|
||||
loc1:
|
||||
.hDC HDC ?
|
||||
.hMemDC HDC ?
|
||||
.hSurfaceBmp HBITMAP ?
|
||||
.hDefaultBmp HBITMAP ?
|
||||
.hDefaultFont HFONT ?
|
||||
.rect_Client rb RECT.size
|
||||
.bkMode INT32 ?
|
||||
.size = $
|
||||
end virtual
|
||||
; --------------------------------------------------------------------------
|
||||
align PROC_ALIGN
|
||||
TApp_WmPaint:
|
||||
mcBeginLocals loc1.size
|
||||
mcStoreLocal loc1.hDC, eax
|
||||
|
||||
mcLoadLocalRef edi, loc1.rect_Client
|
||||
invoke GetClientRect, [glb_MainWnd], edi
|
||||
|
||||
mcLoadLocal edx, loc1.hDC
|
||||
invoke CreateCompatibleDC, edx
|
||||
mcStoreLocal loc1.hMemDC, eax
|
||||
|
||||
mov ebx, esp
|
||||
invoke CreateCompatibleBitmap, [ebx + loc1.hDC], \
|
||||
dword [ebx + loc1.rect_Client + RECT.rc_Right], \
|
||||
dword [ebx + loc1.rect_Client + RECT.rc_Bottom]
|
||||
|
||||
mcStoreLocal loc1.hSurfaceBmp, eax
|
||||
|
||||
invoke SelectObject, [ebx + loc1.hMemDC], eax
|
||||
mcStoreLocal loc1.hDefaultBmp, eax
|
||||
|
||||
invoke GetStockObject, BLACK_BRUSH
|
||||
mcLoadLocalRef esi, loc1.rect_Client
|
||||
invoke FillRect, [ebx + loc1.hMemDC], esi, eax
|
||||
|
||||
invoke SetBkMode, [ebx + loc1.hMemDC], TRANSPARENT
|
||||
mcStoreLocal loc1.bkMode, eax
|
||||
|
||||
invoke SelectObject, [ebx + loc1.hMemDC], [glb_Font]
|
||||
mcStoreLocal loc1.hDefaultFont, eax
|
||||
|
||||
mcLoadLocal edx, loc1.hMemDC
|
||||
call TConsole_DrawAllLines
|
||||
|
||||
mov ebx, esp
|
||||
invoke SetBkMode, [ebx + loc1.hMemDC], [ebx + loc1.bkMode]
|
||||
invoke SelectObject, [ebx + loc1.hMemDC], [ebx + loc1.hDefaultFont]
|
||||
|
||||
mcZeroBits ecx
|
||||
|
||||
invoke BitBlt, [ebx + loc1.hDC], ecx, ecx, \
|
||||
dword [ebx + loc1.rect_Client + RECT.rc_Right], \
|
||||
dword [ebx + loc1.rect_Client + RECT.rc_Bottom], \
|
||||
[ebx + loc1.hMemDC], ecx, ecx, SRCCOPY
|
||||
|
||||
invoke SelectObject, [ebx + loc1.hMemDC], [ebx + loc1.hDefaultBmp]
|
||||
invoke DeleteObject, [ebx + loc1.hSurfaceBmp]
|
||||
invoke DeleteDC, [ebx + loc1.hMemDC]
|
||||
|
||||
mcEndLocals loc1.size
|
||||
ret
|
||||
|
||||
; --------------------------------------------------------------------------
|
||||
; Input:
|
||||
; EAX = WCHAR received from user
|
||||
; --------------------------------------------------------------------------
|
||||
align PROC_ALIGN
|
||||
TApp_WmChar:
|
||||
and eax, 0FFh
|
||||
|
||||
cmp al, 20h
|
||||
jb .control_char
|
||||
|
||||
cmp al, 'a'
|
||||
jb .draw_symbol
|
||||
cmp al, 'z'
|
||||
ja .draw_symbol
|
||||
|
||||
sub al, 20h
|
||||
|
||||
.draw_symbol:
|
||||
mov cl, ATTR_PROMPT_VALUE
|
||||
call TConsole_SetAttr
|
||||
call TCmdBuf_PutChar
|
||||
call TConsole_PutChar
|
||||
call TConsole_RefreshCaretLine
|
||||
ret
|
||||
|
||||
.backspace:
|
||||
call TCmdBuf_IsEmpty
|
||||
jnc .del_last_char
|
||||
ret
|
||||
|
||||
.del_last_char:
|
||||
call TCmdBuf_Backspace
|
||||
call TConsole_Backspace
|
||||
ret
|
||||
|
||||
.command_complete:
|
||||
call TConsole_ScrollUp
|
||||
call TCmdBuf_Parse
|
||||
lock inc [glb_GameThreadBusy]
|
||||
ret
|
||||
|
||||
.key_escape:
|
||||
ret
|
||||
|
||||
.control_char:
|
||||
cmp al, CHAR_BACKSPACE
|
||||
je .backspace
|
||||
cmp al, CHAR_ENTER
|
||||
je .command_complete
|
||||
cmp al, CHAR_ESC
|
||||
je .key_escape
|
||||
ret
|
||||
|
||||
; --------------------------------------------------------------------------
|
||||
align PROC_ALIGN
|
||||
TApp_QueryTextSize:
|
||||
invoke GetDC, 0
|
||||
mov esi, eax
|
||||
|
||||
invoke SelectObject, eax, [glb_Font]
|
||||
push eax
|
||||
|
||||
invoke GetTextExtentPoint32, esi, str_CharSizeText, 2, glb_CharSize
|
||||
|
||||
pop edx
|
||||
invoke SelectObject, esi, edx
|
||||
|
||||
invoke ReleaseDC, 0, esi
|
||||
|
||||
shr dword [glb_CharSize + SIZE.size_Width], 1
|
||||
ret
|
||||
|
||||
; --------------------------------------------------------------------------
|
||||
; Input:
|
||||
; ESI = address of rectangle to redraw
|
||||
; --------------------------------------------------------------------------
|
||||
align PROC_ALIGN
|
||||
TApp_RefreshMainWndRect:
|
||||
mov ebx, [glb_MainWnd]
|
||||
invoke InvalidateRect, ebx, esi, 1
|
||||
invoke UpdateWindow, ebx
|
||||
ret
|
||||
|
||||
; --------------------------------------------------------------------------
|
||||
align PROC_ALIGN
|
||||
TApp_AdjustWndRect:
|
||||
mcBeginLocals RECT.size
|
||||
|
||||
mov esi, esp
|
||||
|
||||
mcZeroBits eax
|
||||
mov [esi + RECT.rc_Left], eax
|
||||
mov [esi + RECT.rc_Top], eax
|
||||
|
||||
mov ecx, dword [glb_CharSize + SIZE.size_Width]
|
||||
imul ecx, CONSOLE_COLS
|
||||
add ecx, 2
|
||||
mov [esi + RECT.rc_Right], ecx
|
||||
|
||||
mov ecx, dword [glb_CharSize + SIZE.size_Height]
|
||||
imul ecx, CONSOLE_ROWS
|
||||
add ecx, 2
|
||||
mov [esi + RECT.rc_Bottom], ecx
|
||||
|
||||
invoke OffsetRect, esi, 200, 32
|
||||
invoke AdjustWindowRect, esi, WS_NOSIZEWND, 0
|
||||
|
||||
mcRectWidth ecx, esi
|
||||
mcRectHeight edx, esi
|
||||
|
||||
invoke MoveWindow, [glb_MainWnd], \
|
||||
[esi + RECT.rc_Left], \
|
||||
[esi + RECT.rc_Top], \
|
||||
ecx, edx, 0
|
||||
|
||||
mcEndLocals RECT.size
|
||||
ret
|
||||
|
||||
; --------------------------------------------------------------------------
|
||||
align PROC_ALIGN
|
||||
TApp_WmCreate:
|
||||
call TCommon_Allocate
|
||||
call TMsgTable_Load
|
||||
call TCmdBuf_Create
|
||||
call TApp_QueryTextSize
|
||||
call TApp_AdjustWndRect
|
||||
|
||||
invoke PostMessage, [glb_MainWnd], WM_CUSTOM_DO_PRELIM, 0, 0
|
||||
ret
|
||||
|
||||
; --------------------------------------------------------------------------
|
||||
; Input:
|
||||
; hWnd, uiMsg, WParam, LParam
|
||||
; --------------------------------------------------------------------------
|
||||
align PROC_ALIGN
|
||||
TApp_WndProc:
|
||||
mcProlog
|
||||
|
||||
mov eax, uiMsg
|
||||
mcOnRegEqu eax, WM_CREATE, .OnCreate
|
||||
mcOnRegEqu eax, WM_DESTROY, .OnDestroy
|
||||
mcOnRegEqu eax, WM_ERASEBKGND, .OnEraseBkGnd
|
||||
mcOnRegEqu eax, WM_PAINT, .OnPaint
|
||||
mcOnRegEqu eax, WM_CHAR, .OnChar
|
||||
mcOnRegEqu eax, WM_CUSTOM_DO_PRELIM, .StartGameThread
|
||||
|
||||
invoke DefWindowProc, hWnd, uiMsg, WParam, LParam
|
||||
|
||||
.exit:
|
||||
mcEpilog
|
||||
ret 10h
|
||||
|
||||
.StartGameThread:
|
||||
invoke CreateThread, 0, 0, TGame_Thread, 0, 0, 0
|
||||
|
||||
.ret_zero:
|
||||
mcZeroBits eax
|
||||
jmp .exit
|
||||
|
||||
.OnCreate:
|
||||
mov eax, hWnd
|
||||
mov [glb_MainWnd], eax
|
||||
call TApp_WmCreate
|
||||
jmp .ret_zero
|
||||
|
||||
.OnDestroy:
|
||||
invoke PostQuitMessage, 0
|
||||
jmp .ret_zero
|
||||
|
||||
.OnEraseBkGnd:
|
||||
mcLoad1 eax
|
||||
jmp .exit
|
||||
|
||||
.OnPaint:
|
||||
mcBeginLocals PAINTSTRUCT.size
|
||||
invoke BeginPaint, [glb_MainWnd], esp
|
||||
call TApp_WmPaint
|
||||
invoke EndPaint, [glb_MainWnd], esp
|
||||
mcEndLocals PAINTSTRUCT.size
|
||||
jmp .ret_zero
|
||||
|
||||
.OnChar:
|
||||
mcZeroBits eax
|
||||
lock add [glb_GameThreadBusy], eax
|
||||
jnz .ret_zero
|
||||
|
||||
mov eax, WParam
|
||||
call TApp_WmChar
|
||||
jmp .ret_zero
|
||||
|
||||
; --------------------------------------------------------------------------
|
||||
align PROC_ALIGN
|
||||
TApp_CreateFont:
|
||||
mcBeginLocals LOGFONT.size
|
||||
|
||||
mov edi, esp
|
||||
mov ecx, LOGFONT.size
|
||||
mcZeroBits eax
|
||||
rep stosb
|
||||
|
||||
mov edx, FW_NORMAL
|
||||
mov [esp + LOGFONT.lf_Weight], edx
|
||||
|
||||
mov dl, DEFAULT_CHARSET
|
||||
mov [esp + LOGFONT.lf_CharSet], dl
|
||||
|
||||
lea edi, [esp + LOGFONT.lf_FaceName]
|
||||
mov esi, str_FontFace
|
||||
call TString_Copy
|
||||
|
||||
invoke GetDC, 0
|
||||
mov esi, eax
|
||||
invoke GetDeviceCaps, esi, LOGPIXELSY
|
||||
invoke MulDiv, 12, eax, 72
|
||||
|
||||
neg eax
|
||||
mov [esp + LOGFONT.lf_Height], eax
|
||||
invoke ReleaseDC, 0, esi
|
||||
|
||||
invoke CreateFontIndirect, esp
|
||||
mov [glb_Font], eax
|
||||
|
||||
mcEndLocals LOGFONT.size
|
||||
ret
|
||||
|
||||
; --------------------------------------------------------------------------
|
||||
align PROC_ALIGN
|
||||
TApp_RegisterWnd:
|
||||
mcBeginLocals WNDCLASS.size
|
||||
|
||||
mov ebx, esp
|
||||
|
||||
mcZeroBits ecx
|
||||
mcStoreMember WNDCLASS.wc_lpszMenuName, ecx
|
||||
mcStoreMember WNDCLASS.wc_cbClsExtra, ecx
|
||||
mcStoreMember WNDCLASS.wc_cbWndExtra, ecx
|
||||
mcStoreMember WNDCLASS.wc_hbrBackground, ecx
|
||||
|
||||
invoke LoadCursor, 0, IDC_ARROW
|
||||
mcStoreMember WNDCLASS.wc_hCursor, eax
|
||||
|
||||
invoke LoadIcon, 0, IDI_EXCLAMATION
|
||||
mcStoreMember WNDCLASS.wc_hIcon, eax
|
||||
|
||||
mov eax, [glb_Instance]
|
||||
mcStoreMember WNDCLASS.wc_hInstance, eax
|
||||
|
||||
mov eax, TApp_WndProc
|
||||
mcStoreMember WNDCLASS.wc_lpfnWndProc, eax
|
||||
|
||||
mov eax, str_MainWndClass
|
||||
mcStoreMember WNDCLASS.wc_lpszClassName, eax
|
||||
|
||||
invoke RegisterClass, ebx
|
||||
|
||||
mcEndLocals WNDCLASS.size
|
||||
ret
|
||||
|
||||
; --------------------------------------------------------------------------
|
||||
align PROC_ALIGN
|
||||
TApp_CreateMainWnd:
|
||||
invoke CreateWindowEx, WS_EX_APPWINDOW, str_MainWndClass, \
|
||||
str_MainWndTitle, WS_NOSIZEWND, \
|
||||
80, 40, 500, 500, \
|
||||
0, 0, [glb_Instance], 0
|
||||
ret
|
||||
|
||||
; --------------------------------------------------------------------------
|
||||
align PROC_ALIGN
|
||||
TApp_Init:
|
||||
invoke GetModuleHandle, 0
|
||||
mov [glb_Instance], eax
|
||||
|
||||
invoke HeapCreate, HEAP_NO_SERIALIZE, 0x20000, 0
|
||||
mov [glb_Allocator], eax
|
||||
|
||||
call TRandom_Create
|
||||
call TApp_RegisterWnd
|
||||
call TApp_CreateFont
|
||||
call TApp_CreateMainWnd
|
||||
call TConsole_Create
|
||||
call TLog_Create
|
||||
ret
|
||||
|
||||
; --------------------------------------------------------------------------
|
||||
align PROC_ALIGN
|
||||
TApp_Run:
|
||||
mcBeginLocals MSG.size
|
||||
|
||||
mov esi, [glb_MainWnd]
|
||||
invoke ShowWindow, esi, SW_SHOWNORMAL
|
||||
invoke UpdateWindow, esi
|
||||
|
||||
@@:
|
||||
mcZeroBits eax
|
||||
mov edi, esp
|
||||
invoke GetMessage, edi, eax, eax, eax
|
||||
mcOnRegZero eax, .done
|
||||
|
||||
invoke TranslateMessage, edi
|
||||
invoke DispatchMessage, edi
|
||||
jmp @r
|
||||
|
||||
.done:
|
||||
call TLog_Disable
|
||||
|
||||
mcEndLocals MSG.size
|
||||
ret
|
||||
|
||||
; --- EOF ---
|
677
programs/games/StarTrek/trunk/TArray.Asm
Normal file
677
programs/games/StarTrek/trunk/TArray.Asm
Normal file
@ -0,0 +1,677 @@
|
||||
; --------------------------------------------------------------------------
|
||||
; FILE: TArray.Asm
|
||||
; DATE: October 4, 2008
|
||||
; --------------------------------------------------------------------------
|
||||
|
||||
; --------------------------------------------------------------------------
|
||||
; LEAVE
|
||||
; --------------------------------------------------------------------------
|
||||
; Input:
|
||||
; ECX = 1-based index (IESC) of the leaving enemy
|
||||
; --------------------------------------------------------------------------
|
||||
align PROC_ALIGN
|
||||
TArray_Leave:
|
||||
pushad
|
||||
|
||||
mcLoadGameDataPtr ebx
|
||||
movzx edx, [ebx + TREKDATA.NENHERE]
|
||||
dec edx
|
||||
dec ecx
|
||||
|
||||
mcLoadMemberRef edi, TREKDATA.KX
|
||||
mov al, [edi + edx]
|
||||
mov [edi + ecx], al
|
||||
|
||||
mcLoadMemberRef edi, TREKDATA.KY
|
||||
mov al, [edi + edx]
|
||||
mov [edi + ecx], al
|
||||
|
||||
imul ecx, 10
|
||||
imul edx, 10
|
||||
|
||||
mcLoadMemberRef edi, TREKDATA.KPOWER
|
||||
fld tbyte [edi + edx]
|
||||
fstp tbyte [edi + ecx]
|
||||
|
||||
mcLoadMemberRef edi, TREKDATA.KDIST
|
||||
fld tbyte [edi + edx]
|
||||
fstp tbyte [edi + ecx]
|
||||
|
||||
dec [ebx + TREKDATA.KLHERE]
|
||||
dec [ebx + TREKDATA.NENHERE]
|
||||
|
||||
cmp [ebx + TREKDATA.CONDIT], CONDITION_DOCKED
|
||||
je .done
|
||||
|
||||
call TCommon_NewCondition
|
||||
|
||||
.done:
|
||||
popad
|
||||
ret
|
||||
|
||||
; --------------------------------------------------------------------------
|
||||
; Input:
|
||||
; EDI = array relative offset
|
||||
; ECX = 1-based index of DOUBLE cell
|
||||
; ST(0) = value to store
|
||||
; --------------------------------------------------------------------------
|
||||
align PROC_ALIGN
|
||||
TArray_SetDouble:
|
||||
push eax ecx
|
||||
movzx ecx, cl
|
||||
dec ecx
|
||||
imul ecx, 10
|
||||
mcLoadGameDataPtr eax
|
||||
add edi, eax
|
||||
fstp tbyte [edi + ecx]
|
||||
pop ecx eax
|
||||
ret
|
||||
|
||||
; --------------------------------------------------------------------------
|
||||
; Input:
|
||||
; CL = 1-based index of KPOWER cell
|
||||
; Output:
|
||||
; EDX = address of that DOUBLE cell
|
||||
; --------------------------------------------------------------------------
|
||||
align PROC_ALIGN
|
||||
TArray_KlingonPowerPtr:
|
||||
push ecx
|
||||
movzx ecx, cl
|
||||
mcLoadGameDataPtr edx
|
||||
add edx, TREKDATA.KPOWER
|
||||
dec ecx
|
||||
imul ecx, 10
|
||||
add edx, ecx
|
||||
pop ecx
|
||||
ret
|
||||
|
||||
; --------------------------------------------------------------------------
|
||||
; Input:
|
||||
; EDI = array relative offset
|
||||
; CL = 1-based index of DOUBLE cell
|
||||
; Output:
|
||||
; ST(0) = loaded value
|
||||
; --------------------------------------------------------------------------
|
||||
align PROC_ALIGN
|
||||
TArray_GetDouble:
|
||||
push eax ecx
|
||||
movzx ecx, cl
|
||||
dec ecx
|
||||
imul ecx, 10
|
||||
mcLoadGameDataPtr eax
|
||||
add edi, eax
|
||||
fld tbyte [edi + ecx]
|
||||
pop ecx eax
|
||||
ret
|
||||
|
||||
; --------------------------------------------------------------------------
|
||||
; Input:
|
||||
; CL = 1-based index of DAMAGE cell
|
||||
; Output:
|
||||
; ST(0) = loaded value
|
||||
; --------------------------------------------------------------------------
|
||||
align PROC_ALIGN
|
||||
TArray_GetDblDamage:
|
||||
push edi
|
||||
mcLoad8bitsToReg32 edi, TREKDATA.DAMAGE
|
||||
call TArray_GetDouble
|
||||
pop edi
|
||||
ret
|
||||
|
||||
; --------------------------------------------------------------------------
|
||||
; Input:
|
||||
; CL = 1-based index of DEVICE
|
||||
; Output:
|
||||
; CF=1 if device is damaged
|
||||
; --------------------------------------------------------------------------
|
||||
align PROC_ALIGN
|
||||
TArray_IsDamaged:
|
||||
call TArray_GetDblDamage
|
||||
fldz
|
||||
mc_CMP_ST0_ST1
|
||||
jz .no_damage
|
||||
|
||||
stc
|
||||
ret
|
||||
|
||||
.no_damage:
|
||||
clc
|
||||
ret
|
||||
|
||||
; --------------------------------------------------------------------------
|
||||
; Input:
|
||||
; ECX = 1-based index of KPOWER cell
|
||||
; Output:
|
||||
; ST(0) = loaded value
|
||||
; --------------------------------------------------------------------------
|
||||
align PROC_ALIGN
|
||||
TArray_GetDblKPower:
|
||||
push edi
|
||||
mcLoad8bitsToReg32 edi, TREKDATA.KPOWER
|
||||
call TArray_GetDouble
|
||||
pop edi
|
||||
ret
|
||||
|
||||
; --------------------------------------------------------------------------
|
||||
; Input:
|
||||
; ECX = 1-based index of KDIST cell
|
||||
; Output:
|
||||
; ST(0) = loaded value
|
||||
; --------------------------------------------------------------------------
|
||||
align PROC_ALIGN
|
||||
TArray_GetDblKDist:
|
||||
push edi
|
||||
mcLoad8bitsToReg32 edi, TREKDATA.KDIST
|
||||
call TArray_GetDouble
|
||||
pop edi
|
||||
ret
|
||||
|
||||
; --------------------------------------------------------------------------
|
||||
; Input:
|
||||
; ECX = 1-based index of DAMAGE cell
|
||||
; ST(0) = value to store
|
||||
; --------------------------------------------------------------------------
|
||||
align PROC_ALIGN
|
||||
TArray_SetDblDamage:
|
||||
push edi
|
||||
mcLoad8bitsToReg32 edi, TREKDATA.DAMAGE
|
||||
call TArray_SetDouble
|
||||
pop edi
|
||||
ret
|
||||
|
||||
; --------------------------------------------------------------------------
|
||||
; Input:
|
||||
; ECX = 1-based index of KPOWER cell
|
||||
; ST(0) = value to store
|
||||
; --------------------------------------------------------------------------
|
||||
align PROC_ALIGN
|
||||
TArray_SetDblKPower:
|
||||
push edi
|
||||
mcLoad8bitsToReg32 edi, TREKDATA.KPOWER
|
||||
call TArray_SetDouble
|
||||
pop edi
|
||||
ret
|
||||
|
||||
; --------------------------------------------------------------------------
|
||||
; Input:
|
||||
; ECX = 1-based index of KDIST cell
|
||||
; ST(0) = value to store
|
||||
; --------------------------------------------------------------------------
|
||||
align PROC_ALIGN
|
||||
TArray_SetDblKDist:
|
||||
push edi
|
||||
mcLoad8bitsToReg32 edi, TREKDATA.KDIST
|
||||
call TArray_SetDouble
|
||||
pop edi
|
||||
ret
|
||||
|
||||
; --------------------------------------------------------------------------
|
||||
; Input:
|
||||
; AL = X coordinate in range [1..10]
|
||||
; DL = Y coordinate in range [1..10]
|
||||
; Output:
|
||||
; EBX = address of QUAD (X,Y)
|
||||
; NOTE:
|
||||
; Coordinates are preserved during the call
|
||||
; --------------------------------------------------------------------------
|
||||
align PROC_ALIGN
|
||||
TArray_QuadPtr:
|
||||
push eax ecx edx
|
||||
;
|
||||
; I = (X-1)*10 + (Y-1)
|
||||
;
|
||||
dec al
|
||||
dec dl
|
||||
cbw
|
||||
imul ax, 10
|
||||
add al, dl
|
||||
movzx ecx, al
|
||||
;
|
||||
; Load address into EBX
|
||||
;
|
||||
mov ebx, [glb_pGameData]
|
||||
lea ebx, [ebx + ecx + TREKDATA.QUAD]
|
||||
|
||||
pop edx ecx eax
|
||||
ret
|
||||
|
||||
; --------------------------------------------------------------------------
|
||||
; Output:
|
||||
; CF=TRUE if CHAR_WEB is the only element encountered around
|
||||
; the quadrant edges.
|
||||
; --------------------------------------------------------------------------
|
||||
align PROC_ALIGN
|
||||
TArray_IsWebComplete:
|
||||
;
|
||||
; Check the way from sector 1-1 to sector 1-10
|
||||
;
|
||||
mcLoad1 eax
|
||||
mov edx, eax
|
||||
call TArray_QuadPtr
|
||||
|
||||
mcLoad8bitsToReg32 ecx, 10
|
||||
mov al, CHAR_WEB
|
||||
|
||||
.check_1:
|
||||
cmp [ebx], al
|
||||
jne .return_false
|
||||
inc ebx
|
||||
loop .check_1
|
||||
;
|
||||
; Check the way from sector 10-1 to sector 10-10
|
||||
;
|
||||
mov al, 10
|
||||
mov dl, 1
|
||||
call TArray_QuadPtr
|
||||
|
||||
mcLoad8bitsToReg32 ecx, 10
|
||||
mov al, CHAR_WEB
|
||||
|
||||
.check_2:
|
||||
cmp [ebx], al
|
||||
jne .return_false
|
||||
inc ebx
|
||||
loop .check_2
|
||||
;
|
||||
; Check the vertical ways:
|
||||
; 1. From sector 1-1 to sector 10-1
|
||||
; 2. From sector 1-10 to sector 10-10
|
||||
;
|
||||
mov al, 2
|
||||
mov dl, 1
|
||||
call TArray_QuadPtr
|
||||
|
||||
mcLoad8bitsToReg32 ecx, 8
|
||||
mov al, CHAR_WEB
|
||||
|
||||
.check_3:
|
||||
cmp [ebx], al
|
||||
jne .return_false
|
||||
cmp [ebx + 9], al
|
||||
jne .return_false
|
||||
|
||||
add ebx, 10
|
||||
loop .check_3
|
||||
;
|
||||
; All plugged!
|
||||
;
|
||||
stc
|
||||
ret
|
||||
|
||||
.return_false:
|
||||
clc
|
||||
ret
|
||||
|
||||
; --------------------------------------------------------------------------
|
||||
align PROC_ALIGN
|
||||
TArray_SetShip:
|
||||
mcLoadGameDataPtr ebx
|
||||
mcLoadMember al, TREKDATA.SECTX
|
||||
mcLoadMember dl, TREKDATA.SECTY
|
||||
push ebx
|
||||
call TArray_QuadPtr
|
||||
pop esi
|
||||
|
||||
mov al, [esi + TREKDATA.SHIP]
|
||||
mov [ebx], al
|
||||
ret
|
||||
|
||||
; --------------------------------------------------------------------------
|
||||
; Input:
|
||||
; AL = X coordinate in range [1..8]
|
||||
; DL = Y coordinate in range [1..8]
|
||||
; Output:
|
||||
; ECX = index into array (NOT OFFSET)
|
||||
; NOTE:
|
||||
; Coordinates are preserved during the call
|
||||
; --------------------------------------------------------------------------
|
||||
align PROC_ALIGN
|
||||
TArray_8x8Index:
|
||||
;
|
||||
; In STAR TREK cosmos: coordinate X is row and
|
||||
; coordinate Y is column in the matrix, so
|
||||
; index is calculated as:
|
||||
;
|
||||
; I = (X-1)*8 + (Y-1)
|
||||
;
|
||||
push eax edx
|
||||
dec al
|
||||
dec dl
|
||||
shl al, 3
|
||||
add al, dl
|
||||
movzx ecx, al
|
||||
pop edx eax
|
||||
ret
|
||||
|
||||
; --------------------------------------------------------------------------
|
||||
; Input:
|
||||
; AL = X coordinate in range [1..8]
|
||||
; DL = Y coordinate in range [1..8]
|
||||
; Output:
|
||||
; EBX = address of SCANNED (8,8) cell
|
||||
; NOTE:
|
||||
; All registers are preserved
|
||||
; --------------------------------------------------------------------------
|
||||
align PROC_ALIGN
|
||||
TArray_ScannedQuadPtr:
|
||||
push ecx
|
||||
call TArray_8x8Index
|
||||
mov ebx, [glb_pGameData]
|
||||
lea ebx, [ebx + ecx + TREKDATA.SCANNED]
|
||||
pop ecx
|
||||
ret
|
||||
|
||||
; --------------------------------------------------------------------------
|
||||
; Input:
|
||||
; AL = X coordinate in range [1..8]
|
||||
; DL = Y coordinate in range [1..8]
|
||||
; NOTE:
|
||||
; All registers are preserved
|
||||
; --------------------------------------------------------------------------
|
||||
align PROC_ALIGN
|
||||
TArray_SetScanned:
|
||||
push ebx
|
||||
call TArray_ScannedQuadPtr
|
||||
mov byte [ebx], 1
|
||||
pop ebx
|
||||
ret
|
||||
|
||||
; --------------------------------------------------------------------------
|
||||
; Input:
|
||||
; AL = X coordinate in range [1..8]
|
||||
; DL = Y coordinate in range [1..8]
|
||||
; Output:
|
||||
; CF=TRUE if quadrant was scanned by SRSCAN command
|
||||
; NOTE:
|
||||
; All registers are preserved
|
||||
; --------------------------------------------------------------------------
|
||||
align PROC_ALIGN
|
||||
TArray_IsScanned:
|
||||
push eax
|
||||
push ebx
|
||||
call TArray_ScannedQuadPtr
|
||||
mov al, [ebx]
|
||||
pop ebx
|
||||
shr al, 1
|
||||
pop eax
|
||||
ret
|
||||
|
||||
; --------------------------------------------------------------------------
|
||||
; Input:
|
||||
; AL = X coordinate in range [1..8]
|
||||
; DL = Y coordinate in range [1..8]
|
||||
; Output:
|
||||
; EBX = address of NEWSTUF (8,8) cell
|
||||
; NOTE:
|
||||
; All registers are preserved
|
||||
; --------------------------------------------------------------------------
|
||||
align PROC_ALIGN
|
||||
TArray_NewStufPtr:
|
||||
push ecx
|
||||
call TArray_8x8Index
|
||||
mov ebx, [glb_pGameData]
|
||||
lea ebx, [ebx + ecx + TREKDATA.NEWSTUF]
|
||||
pop ecx
|
||||
ret
|
||||
|
||||
; --------------------------------------------------------------------------
|
||||
; Output:
|
||||
; EBX = address of NEWSTUF (QUADX,QUADY) cell
|
||||
; NOTE:
|
||||
; All registers are preserved
|
||||
; --------------------------------------------------------------------------
|
||||
align PROC_ALIGN
|
||||
TArray_MyNewStufPtr:
|
||||
push eax edx esi
|
||||
mov esi, [glb_pGameData]
|
||||
mov al, [esi + TREKDATA.QUADX]
|
||||
mov dl, [esi + TREKDATA.QUADY]
|
||||
call TArray_NewStufPtr
|
||||
pop esi edx eax
|
||||
ret
|
||||
|
||||
; --------------------------------------------------------------------------
|
||||
; Input:
|
||||
; AL = X coordinate in range [1..8]
|
||||
; DL = Y coordinate in range [1..8]
|
||||
; Output:
|
||||
; EBX = address of GALAXY (8,8) cell
|
||||
; NOTE:
|
||||
; All registers are preserved
|
||||
; --------------------------------------------------------------------------
|
||||
align PROC_ALIGN
|
||||
TArray_GalaxyPtr:
|
||||
push ecx
|
||||
call TArray_8x8Index
|
||||
mov ebx, [glb_pGameData]
|
||||
lea ebx, [ebx + ecx*4 + TREKDATA.GALAXY]
|
||||
pop ecx
|
||||
ret
|
||||
|
||||
; --------------------------------------------------------------------------
|
||||
; Input:
|
||||
; AL = quadrant X coordinate in range [1..8]
|
||||
; DL = quadrant Y coordinate in range [1..8]
|
||||
; ESI = TPlanet address
|
||||
; Output:
|
||||
; CF=1 if location is matching PLNETS array item
|
||||
; --------------------------------------------------------------------------
|
||||
align PROC_ALIGN
|
||||
TArray_IsPlanetHere:
|
||||
cmp [esi + TPlanet.planet_X], al
|
||||
jne .ret_false
|
||||
|
||||
cmp [esi + TPlanet.planet_Y], dl
|
||||
jne .ret_false
|
||||
|
||||
stc
|
||||
ret
|
||||
|
||||
.ret_false:
|
||||
clc
|
||||
ret
|
||||
|
||||
; --------------------------------------------------------------------------
|
||||
; Input:
|
||||
; AL = quadrant X coordinate in range [1..8]
|
||||
; DL = quadrant Y coordinate in range [1..8]
|
||||
; ECX = commander index (1-based)
|
||||
; Output:
|
||||
; CF=1 if location is matching CX,CY arrays
|
||||
; --------------------------------------------------------------------------
|
||||
align PROC_ALIGN
|
||||
TArray_IsCommanderHere:
|
||||
push ebx ecx esi edi
|
||||
mcLoadGameDataPtr ebx
|
||||
|
||||
mcLoadMemberRef esi, TREKDATA.CX
|
||||
mcLoadMemberRef edi, TREKDATA.CY
|
||||
dec ecx
|
||||
|
||||
cmp [esi + ecx], al
|
||||
jne .ret_false
|
||||
|
||||
cmp [edi + ecx], dl
|
||||
jne .ret_false
|
||||
|
||||
pop edi esi ecx ebx
|
||||
stc
|
||||
ret
|
||||
|
||||
.ret_false:
|
||||
pop edi esi ecx ebx
|
||||
clc
|
||||
ret
|
||||
|
||||
; --------------------------------------------------------------------------
|
||||
; Input:
|
||||
; AL = quadrant X coordinate in range [1..8]
|
||||
; DL = quadrant Y coordinate in range [1..8]
|
||||
; Output:
|
||||
; ECX = 1-based index into PLNETS array or zero
|
||||
; ESI = address of TPlanet structure
|
||||
; --------------------------------------------------------------------------
|
||||
align PROC_ALIGN
|
||||
TArray_FindPlanet:
|
||||
mcLoadGameDataPtr ebx
|
||||
mcLoadMemberRef esi, TREKDATA.PLNETS
|
||||
mcLoad1 ecx
|
||||
|
||||
.check_planet:
|
||||
call TArray_IsPlanetHere
|
||||
jc .done
|
||||
|
||||
inc ecx
|
||||
cmp cl, [ebx + TREKDATA.INPLAN]
|
||||
ja .ret_false
|
||||
|
||||
add esi, TPlanet.size
|
||||
jmp .check_planet
|
||||
|
||||
.ret_false:
|
||||
mcZeroBits ecx
|
||||
|
||||
.done:
|
||||
ret
|
||||
|
||||
; --------------------------------------------------------------------------
|
||||
; Input:
|
||||
; AL = quadrant X coordinate in range [1..8]
|
||||
; DL = quadrant Y coordinate in range [1..8]
|
||||
; Output:
|
||||
; ECX = 1-based index into CX,CY arrays or zero
|
||||
; --------------------------------------------------------------------------
|
||||
align PROC_ALIGN
|
||||
TArray_FindCommander:
|
||||
mcLoadGameDataPtr esi
|
||||
mcLoad1 ecx
|
||||
|
||||
.scan:
|
||||
call TArray_IsCommanderHere
|
||||
jc .found_it
|
||||
|
||||
inc ecx
|
||||
cmp cl, [esi + TREKDATA.REMCOM]
|
||||
jbe .scan
|
||||
|
||||
mcZeroBits ecx
|
||||
|
||||
.found_it:
|
||||
ret
|
||||
|
||||
; --------------------------------------------------------------------------
|
||||
; Input:
|
||||
; ECX = planet index (1-based)
|
||||
; Output:
|
||||
; EDI = address of TPlanet structure
|
||||
; --------------------------------------------------------------------------
|
||||
align PROC_ALIGN
|
||||
TArray_PlanetPtr:
|
||||
dec ecx
|
||||
mcLoadGameDataPtr edi
|
||||
imul ecx, TPlanet.size
|
||||
lea edi, [edi + ecx + TREKDATA.PLNETS]
|
||||
ret
|
||||
|
||||
; --------------------------------------------------------------------------
|
||||
; Output:
|
||||
; EBX = address of GALAXY (QUADX,QUADY) cell
|
||||
; NOTE:
|
||||
; All registers are preserved
|
||||
; --------------------------------------------------------------------------
|
||||
align PROC_ALIGN
|
||||
TArray_MyGalaxyPtr:
|
||||
push eax edx esi
|
||||
mov esi, [glb_pGameData]
|
||||
mov al, [esi + TREKDATA.QUADX]
|
||||
mov dl, [esi + TREKDATA.QUADY]
|
||||
call TArray_GalaxyPtr
|
||||
pop esi edx eax
|
||||
ret
|
||||
|
||||
; --------------------------------------------------------------------------
|
||||
; Input:
|
||||
; AL = X coordinate in range [1..8]
|
||||
; DL = Y coordinate in range [1..8]
|
||||
; Output:
|
||||
; EBX = address of STARCH (8,8) cell
|
||||
; NOTE:
|
||||
; All registers are preserved
|
||||
; --------------------------------------------------------------------------
|
||||
align PROC_ALIGN
|
||||
TArray_StarChartPtr:
|
||||
push ecx
|
||||
call TArray_8x8Index
|
||||
mov ebx, [glb_pGameData]
|
||||
lea ebx, [ebx + ecx*4 + TREKDATA.STARCH]
|
||||
pop ecx
|
||||
ret
|
||||
|
||||
; --------------------------------------------------------------------------
|
||||
; Input:
|
||||
; AL = X coordinate in range [1..8]
|
||||
; DL = Y coordinate in range [1..8]
|
||||
; Output:
|
||||
; ECX = value of STARCH (8,8) cell
|
||||
; NOTE:
|
||||
; All registers are preserved
|
||||
; --------------------------------------------------------------------------
|
||||
align PROC_ALIGN
|
||||
TArray_GetStarChartValue:
|
||||
push ebx
|
||||
call TArray_StarChartPtr
|
||||
mov ecx, [ebx]
|
||||
pop ebx
|
||||
ret
|
||||
|
||||
; --------------------------------------------------------------------------
|
||||
; Input:
|
||||
; AL = X coordinate in range [1..8]
|
||||
; DL = Y coordinate in range [1..8]
|
||||
; Output:
|
||||
; ECX = value of GALAXY (8,8) cell
|
||||
; NOTE:
|
||||
; All registers are preserved
|
||||
; --------------------------------------------------------------------------
|
||||
align PROC_ALIGN
|
||||
TArray_GetGalaxyValue:
|
||||
push ebx
|
||||
call TArray_GalaxyPtr
|
||||
mov ecx, [ebx]
|
||||
pop ebx
|
||||
ret
|
||||
|
||||
; --------------------------------------------------------------------------
|
||||
; Input:
|
||||
; AL = X coordinate in range [1..8]
|
||||
; DL = Y coordinate in range [1..8]
|
||||
; ECX = value to set at STARCH (8,8) cell
|
||||
; NOTE:
|
||||
; All registers are preserved
|
||||
; --------------------------------------------------------------------------
|
||||
align PROC_ALIGN
|
||||
TArray_SetStarChartValue:
|
||||
push ebx
|
||||
call TArray_StarChartPtr
|
||||
mov [ebx], ecx
|
||||
pop ebx
|
||||
ret
|
||||
|
||||
; --------------------------------------------------------------------------
|
||||
; Input:
|
||||
; AL = X coordinate in range [1..8]
|
||||
; DL = Y coordinate in range [1..8]
|
||||
; ECX = value to set at GALAXY (8,8) cell
|
||||
; NOTE:
|
||||
; All registers are preserved
|
||||
; --------------------------------------------------------------------------
|
||||
align PROC_ALIGN
|
||||
TArray_SetGalaxyValue:
|
||||
push ebx
|
||||
call TArray_GalaxyPtr
|
||||
mov [ebx], ecx
|
||||
pop ebx
|
||||
ret
|
||||
|
||||
|
||||
; --- EOF ---
|
1813
programs/games/StarTrek/trunk/TAttack.Asm
Normal file
1813
programs/games/StarTrek/trunk/TAttack.Asm
Normal file
File diff suppressed because it is too large
Load Diff
317
programs/games/StarTrek/trunk/TChart.Asm
Normal file
317
programs/games/StarTrek/trunk/TChart.Asm
Normal file
@ -0,0 +1,317 @@
|
||||
; --------------------------------------------------------------------------
|
||||
; FILE: TChart.Asm
|
||||
; DATE: October 12, 2008
|
||||
; --------------------------------------------------------------------------
|
||||
|
||||
; --------------------------------------------------------------------------
|
||||
; Input:
|
||||
; EAX = X quadrant coordinate
|
||||
; EDX = Y quadrant coordinate
|
||||
; --------------------------------------------------------------------------
|
||||
align PROC_ALIGN
|
||||
TChart_SetQuadAttr:
|
||||
push ebx ecx
|
||||
|
||||
mcLoadGameDataPtr ebx
|
||||
cmp al, [ebx + TREKDATA.QUADX]
|
||||
jne .no_ship_here
|
||||
cmp dl, [ebx + TREKDATA.QUADY]
|
||||
je .ship_here
|
||||
|
||||
.no_ship_here:
|
||||
call TArray_IsScanned
|
||||
jc .set_scanned_color
|
||||
|
||||
mov cl, ATTR_REPORT_VALUE
|
||||
jmp .apply
|
||||
|
||||
.set_scanned_color:
|
||||
mov cl, ATTR_PLANET
|
||||
jmp .apply
|
||||
|
||||
.ship_here:
|
||||
mov cl, ATTR_SHIP_QUAD
|
||||
|
||||
.apply:
|
||||
call TConsole_SetAttr
|
||||
pop ecx ebx
|
||||
ret
|
||||
|
||||
; --------------------------------------------------------------------------
|
||||
; CHART
|
||||
; --------------------------------------------------------------------------
|
||||
virtual at 0
|
||||
loc25:
|
||||
.nI INDEX ?
|
||||
.nJ INDEX ?
|
||||
.size = $
|
||||
end virtual
|
||||
; --------------------------------------------------------------------------
|
||||
align PROC_ALIGN
|
||||
TChart_Main:
|
||||
mcBeginLocals loc25.size
|
||||
|
||||
mov cl, ATTR_REPORT_TEXT
|
||||
call TConsole_SetAttr
|
||||
mcLoad8bitsToReg32 ecx, 136
|
||||
call TConsole_Prout
|
||||
|
||||
mov cl, ATTR_SCAN_SCALE
|
||||
call TConsole_SetAttr
|
||||
mcLoad8bitsToReg32 ecx, 137
|
||||
call TConsole_Prout
|
||||
mcLoad8bitsToReg32 ecx, 138
|
||||
call TConsole_Prout
|
||||
mcLoad8bitsToReg32 ecx, 139
|
||||
call TConsole_Prout
|
||||
|
||||
mcLoad1 eax
|
||||
mcStoreLocal loc25.nI, eax
|
||||
|
||||
.row_begins:
|
||||
mov cl, ATTR_SCAN_SCALE
|
||||
call TConsole_SetAttr
|
||||
|
||||
mcLoadLocal eax, loc25.nI
|
||||
call TConsole_CramInt
|
||||
mcLoad8bitsToReg32 ecx, 140
|
||||
call TConsole_Cram
|
||||
|
||||
mcLoad1 ecx
|
||||
mcStoreLocal loc25.nJ, ecx
|
||||
|
||||
.load_chart_value:
|
||||
mcLoadLocal eax, loc25.nI
|
||||
mcLoadLocal edx, loc25.nJ
|
||||
|
||||
call TChart_SetQuadAttr
|
||||
|
||||
call TArray_GetStarChartValue
|
||||
add ecx, 0
|
||||
js .L10
|
||||
jz .L20
|
||||
|
||||
cmp ecx, 999
|
||||
ja .L35
|
||||
|
||||
call TArray_GetGalaxyValue
|
||||
mov eax, ecx
|
||||
|
||||
.put_value:
|
||||
mov cl, 5
|
||||
call TConsole_CramIntWidth
|
||||
jmp .L40
|
||||
|
||||
.L35:
|
||||
lea eax, [ecx - 1000]
|
||||
jmp .put_value
|
||||
|
||||
.L40:
|
||||
inc [esp + loc25.nJ]
|
||||
cmp [esp + loc25.nJ], 8
|
||||
jbe .load_chart_value
|
||||
|
||||
mov cl, ATTR_SCAN_SCALE
|
||||
call TConsole_SetAttr
|
||||
call TConsole_ScrollUp
|
||||
mcLoad8bitsToReg32 ecx, 139
|
||||
call TConsole_Prout
|
||||
|
||||
inc [esp + loc25.nI]
|
||||
cmp [esp + loc25.nI], 8
|
||||
jbe .row_begins
|
||||
|
||||
call TConsole_ScrollUp
|
||||
mov cl, ATTR_REPORT_TEXT
|
||||
call TConsole_SetAttr
|
||||
mov cl, 2
|
||||
call TConsole_RepeatBlank
|
||||
call TConsole_CramShip
|
||||
mcLoad8bitsToReg32 ecx, 143
|
||||
call TConsole_Cram
|
||||
mov cl, 1
|
||||
mcLoadGameDataPtr esi
|
||||
mov al, [esi + TREKDATA.QUADX]
|
||||
mov dl, [esi + TREKDATA.QUADY]
|
||||
call TConsole_CramLoc
|
||||
jmp .done
|
||||
|
||||
.L10:
|
||||
mcLoad8bitsToReg32 ecx, 141
|
||||
|
||||
.L101:
|
||||
call TConsole_Cram
|
||||
jmp .L40
|
||||
|
||||
.L20:
|
||||
mcLoad8bitsToReg32 ecx, 142
|
||||
jmp .L101
|
||||
|
||||
.done:
|
||||
call TConsole_ScrollUp
|
||||
call TConsole_ScrollUp
|
||||
|
||||
mcEndLocals loc25.size
|
||||
ret
|
||||
|
||||
; --------------------------------------------------------------------------
|
||||
; SETWARP
|
||||
; --------------------------------------------------------------------------
|
||||
virtual at 0
|
||||
loc51:
|
||||
.pTrekData PVOID ?
|
||||
.dbl_OLDFAC DOUBLE ?
|
||||
.dbl_FNUM DOUBLE ?
|
||||
.size = $
|
||||
end virtual
|
||||
; --------------------------------------------------------------------------
|
||||
align PROC_ALIGN
|
||||
TChart_SetWarp:
|
||||
mcBeginLocals loc51.size
|
||||
|
||||
mcLoadGameDataPtr esi
|
||||
mcStoreLocal loc51.pTrekData, esi
|
||||
|
||||
.L10:
|
||||
call TCmdBuf_Scan
|
||||
cmp [ebx + TCmdBuf.cmdbuf_KEY], CMD_TOKEN_EOL
|
||||
jne .L20
|
||||
|
||||
mov ecx, 585
|
||||
call TGame_Prompt
|
||||
jmp .L10
|
||||
|
||||
.L20:
|
||||
cmp [ebx + TCmdBuf.cmdbuf_KEY], CMD_TOKEN_REAL
|
||||
jne .L40
|
||||
|
||||
fld [ebx + TCmdBuf.cmdbuf_FNUM]
|
||||
fstp [esp + loc51.dbl_FNUM]
|
||||
|
||||
mov cl, DEV_WARP_ENGINES
|
||||
call TArray_GetDblDamage
|
||||
fld [glb_dbl_Ten]
|
||||
mc_CMP_ST0_ST1
|
||||
jc .L70
|
||||
|
||||
mov cl, DEV_WARP_ENGINES
|
||||
call TArray_IsDamaged
|
||||
jnc .validate_warp
|
||||
|
||||
fld [esp + loc51.dbl_FNUM]
|
||||
fld [glb_dbl_4]
|
||||
mc_CMP_ST0_ST1
|
||||
jc .L80
|
||||
|
||||
.validate_warp:
|
||||
fld1
|
||||
fld [esp + loc51.dbl_FNUM]
|
||||
mc_CMP_ST0_ST1
|
||||
jc .L50
|
||||
|
||||
fld [esp + loc51.dbl_FNUM]
|
||||
fld [glb_dbl_Ten]
|
||||
mc_CMP_ST0_ST1
|
||||
jc .L60
|
||||
|
||||
mcLoadLocal esi, loc51.pTrekData
|
||||
fld [esi + TREKDATA.WARPFAC]
|
||||
fstp [esp + loc51.dbl_OLDFAC]
|
||||
|
||||
fld [esp + loc51.dbl_FNUM]
|
||||
fstp [esi + TREKDATA.WARPFAC]
|
||||
|
||||
fld [esp + loc51.dbl_FNUM]
|
||||
fld st
|
||||
fmulp
|
||||
fstp [esi + TREKDATA.WFACSQ]
|
||||
|
||||
fld [esp + loc51.dbl_OLDFAC]
|
||||
fld [esi + TREKDATA.WARPFAC]
|
||||
mc_CMP_ST0_ST1
|
||||
jc .L31
|
||||
jz .L31
|
||||
|
||||
fld [glb_dbl_6]
|
||||
fld [esi + TREKDATA.WARPFAC]
|
||||
mc_CMP_ST0_ST1
|
||||
jc .L31
|
||||
jz .L31
|
||||
|
||||
fld [glb_dbl_8]
|
||||
fld [esi + TREKDATA.WARPFAC]
|
||||
mc_CMP_ST0_ST1
|
||||
jc .L32
|
||||
jmp .L33
|
||||
|
||||
.L31:
|
||||
call TConsole_SetCrewMsgAttr
|
||||
mov ecx, 586
|
||||
call TConsole_Cram
|
||||
|
||||
mcLoadLocal esi, loc51.pTrekData
|
||||
fld [esi + TREKDATA.WARPFAC]
|
||||
mov cl, 1
|
||||
call TConsole_CramFloat
|
||||
|
||||
mov ecx, 587
|
||||
call TConsole_Prout
|
||||
jmp .done
|
||||
|
||||
.L32:
|
||||
call TConsole_SetCrewMsgAttr
|
||||
mov ecx, 588
|
||||
call TConsole_Prout
|
||||
jmp .done
|
||||
|
||||
.L33:
|
||||
mcLoadLocal esi, loc51.pTrekData
|
||||
fld [esi + TREKDATA.WARPFAC]
|
||||
fld [glb_dbl_Ten]
|
||||
mc_CMP_ST0_ST1
|
||||
jz .L36
|
||||
|
||||
call TConsole_SetCrewMsgAttr
|
||||
mov ecx, 589
|
||||
call TConsole_Prout
|
||||
jmp .done
|
||||
|
||||
.L36:
|
||||
call TConsole_SetCrewMsgAttr
|
||||
mov ecx, 590
|
||||
call TConsole_Prout
|
||||
jmp .done
|
||||
|
||||
.L40:
|
||||
call TMove_BegPardon
|
||||
jmp .done
|
||||
|
||||
.L50:
|
||||
call TConsole_SetCrewMsgAttr
|
||||
mov ecx, 591
|
||||
call TConsole_Prout
|
||||
jmp .done
|
||||
|
||||
.L60:
|
||||
call TConsole_SetCrewMsgAttr
|
||||
mov ecx, 592
|
||||
call TConsole_Prout
|
||||
jmp .done
|
||||
|
||||
.L70:
|
||||
mov ecx, 593
|
||||
call TConsole_ProutGameMsg
|
||||
jmp .done
|
||||
|
||||
.L80:
|
||||
call TConsole_SetCrewMsgAttr
|
||||
mov ecx, 594
|
||||
call TConsole_Prout
|
||||
mov ecx, 595
|
||||
call TConsole_Prout
|
||||
|
||||
.done:
|
||||
mcEndLocals loc51.size
|
||||
ret
|
||||
|
||||
; --- EOF ---
|
529
programs/games/StarTrek/trunk/TCmdBuf.Asm
Normal file
529
programs/games/StarTrek/trunk/TCmdBuf.Asm
Normal file
@ -0,0 +1,529 @@
|
||||
; --------------------------------------------------------------------------
|
||||
; FILE: TCmdBuf.Asm
|
||||
; DATE: September 27, 2008
|
||||
; --------------------------------------------------------------------------
|
||||
|
||||
; --------------------------------------------------------------------------
|
||||
; Input:
|
||||
; ESI = ANSI token scanned
|
||||
; CL = ANSI text to match (1-based index into message table)
|
||||
; Output:
|
||||
; CF=TRUE if first token exactly matches text at index in CL
|
||||
; CF=FALSE if no match (message given to the user)
|
||||
; --------------------------------------------------------------------------
|
||||
align PROC_ALIGN
|
||||
TCmdBuf_VerifyToken:
|
||||
movzx ecx, cl
|
||||
|
||||
TCmdBuf_VerifyToken_ECX:
|
||||
push esi
|
||||
call TMsgTable_GetItem
|
||||
pop edi
|
||||
|
||||
call TString_AnsiEqual
|
||||
jnc .ret_false
|
||||
ret
|
||||
|
||||
.ret_false:
|
||||
call TConsole_ScrollUp
|
||||
call TConsole_SetGameMsgAttr
|
||||
mcLoad8bitsToReg32 ecx, 93
|
||||
call TConsole_Prout
|
||||
call TConsole_ScrollUp
|
||||
|
||||
clc
|
||||
ret
|
||||
|
||||
; --------------------------------------------------------------------------
|
||||
; Input:
|
||||
; ESI = ANSI token scanned
|
||||
; ECX = ANSI text to match (1-based index into message table)
|
||||
; Output:
|
||||
; CF=TRUE if text at EDI has a prefix like ESI
|
||||
; --------------------------------------------------------------------------
|
||||
align PROC_ALIGN
|
||||
TCmdBuf_Crop:
|
||||
push esi esi
|
||||
call TMsgTable_GetItem
|
||||
mov edi, esi
|
||||
pop esi
|
||||
|
||||
mcZeroBits edx
|
||||
mcZeroBits eax
|
||||
|
||||
.load_chars:
|
||||
lodsb
|
||||
mov dl, [edi]
|
||||
inc edi
|
||||
|
||||
cmp dl, al
|
||||
je .check_zero
|
||||
|
||||
mcOnRegZero eax, .match
|
||||
|
||||
pop esi
|
||||
clc
|
||||
ret
|
||||
|
||||
.check_zero:
|
||||
mcOnRegNotZero eax, .load_chars
|
||||
|
||||
.match:
|
||||
pop esi
|
||||
stc
|
||||
ret
|
||||
|
||||
; --------------------------------------------------------------------------
|
||||
; Input:
|
||||
; AX = WCHAR to append
|
||||
; --------------------------------------------------------------------------
|
||||
align PROC_ALIGN
|
||||
TCmdBuf_PutChar:
|
||||
mov ebx, [glb_pCmdBuf]
|
||||
cmp [ebx + TCmdBuf.cmdbuf_CmdColumn], CMDBUF_MAX_CHARS
|
||||
je .done
|
||||
|
||||
mcLoadMember ecx, TCmdBuf.cmdbuf_CmdColumn
|
||||
mov [ebx + ecx*2], ax
|
||||
inc [ebx + TCmdBuf.cmdbuf_CmdColumn]
|
||||
|
||||
.done:
|
||||
ret
|
||||
|
||||
; --------------------------------------------------------------------------
|
||||
align PROC_ALIGN
|
||||
TCmdBuf_Parse:
|
||||
mcZeroBits eax
|
||||
call TCmdBuf_PutChar
|
||||
|
||||
mov ebx, [glb_pCmdBuf]
|
||||
mcStoreMember TCmdBuf.cmdbuf_NumTokens, eax
|
||||
mcStoreMember TCmdBuf.cmdbuf_CmdColumn, eax
|
||||
|
||||
dec eax
|
||||
mcStoreMember TCmdBuf.cmdbuf_TokenIterator, eax
|
||||
inc eax
|
||||
|
||||
mov esi, ebx
|
||||
mov edx, eax
|
||||
mcLoadMemberRef edi, TCmdBuf.cmdbuf_CmdTokens
|
||||
|
||||
.load_char:
|
||||
lodsw
|
||||
mcOnRegZero eax, .done
|
||||
|
||||
cmp al, CHAR_BLANK
|
||||
je .separator
|
||||
|
||||
mcOnRegNotZero edx, .load_char
|
||||
|
||||
lea edx, [esi - 2]
|
||||
mov [edi], edx
|
||||
add edi, 4
|
||||
inc [ebx + TCmdBuf.cmdbuf_NumTokens]
|
||||
cmp [ebx + TCmdBuf.cmdbuf_NumTokens], CMDBUF_MAX_TOKENS
|
||||
je .done
|
||||
jmp .load_char
|
||||
|
||||
.separator:
|
||||
mcZeroBits edx
|
||||
mov [esi - 2], dx
|
||||
jmp .load_char
|
||||
|
||||
.done:
|
||||
ret
|
||||
|
||||
; --------------------------------------------------------------------------
|
||||
; Input:
|
||||
; AL = character
|
||||
; Output:
|
||||
; CF = TRUE if AL is a digit
|
||||
; --------------------------------------------------------------------------
|
||||
align PROC_ALIGN
|
||||
TCmdBuf_IsDigit:
|
||||
cmp al, '0'
|
||||
jb .false
|
||||
|
||||
cmp al, '9'
|
||||
ja .false
|
||||
|
||||
stc
|
||||
ret
|
||||
|
||||
.false:
|
||||
clc
|
||||
ret
|
||||
|
||||
; --------------------------------------------------------------------------
|
||||
; Input:
|
||||
; ESI = token address
|
||||
; Output:
|
||||
; CF = TRUE if token is a real value: "-100" or "5.6"
|
||||
; --------------------------------------------------------------------------
|
||||
align PROC_ALIGN
|
||||
TCmdBuf_IsRealToken:
|
||||
mcZeroBits ecx
|
||||
mcZeroBits eax
|
||||
mcZeroBits edi
|
||||
|
||||
.load_char:
|
||||
mov ax, [esi + ecx*2]
|
||||
inc ecx
|
||||
mcOnRegZero eax, .true
|
||||
|
||||
mcOnRegEqu al, '-', .minus
|
||||
mcOnRegEqu al, '.', .period
|
||||
;
|
||||
; Check if digit
|
||||
;
|
||||
call TCmdBuf_IsDigit
|
||||
jc .load_char
|
||||
|
||||
.false:
|
||||
clc
|
||||
ret
|
||||
|
||||
.minus:
|
||||
mcOnRegEqu ecx, 1, .load_char
|
||||
jmp .false
|
||||
|
||||
.period:
|
||||
mcOnRegNotZero edi, .false
|
||||
mov edi, esi
|
||||
jmp .load_char
|
||||
|
||||
.true:
|
||||
stc
|
||||
ret
|
||||
|
||||
; --------------------------------------------------------------------------
|
||||
; Output:
|
||||
; ESI = token address or NULL
|
||||
; EAX = token type (CMD_TOKEN_ALPHA, CMD_TOKEN_REAL, CMD_TOKEN_EOL)
|
||||
; --------------------------------------------------------------------------
|
||||
align PROC_ALIGN
|
||||
TCmdBuf_GetNextToken:
|
||||
mov ebx, [glb_pCmdBuf]
|
||||
inc [ebx + TCmdBuf.cmdbuf_TokenIterator]
|
||||
|
||||
mcLoadMember ecx, TCmdBuf.cmdbuf_TokenIterator
|
||||
cmp ecx, [ebx + TCmdBuf.cmdbuf_NumTokens]
|
||||
jae .end_of_line
|
||||
|
||||
mov esi, [ebx + ecx*4 + TCmdBuf.cmdbuf_CmdTokens]
|
||||
call TCmdBuf_IsRealToken
|
||||
jc .real_value
|
||||
|
||||
mcLoad8bitsToReg32 eax, CMD_TOKEN_ALPHA
|
||||
ret
|
||||
|
||||
.real_value:
|
||||
mcLoad8bitsToReg32 eax, CMD_TOKEN_REAL
|
||||
ret
|
||||
|
||||
.end_of_line:
|
||||
mcZeroBits eax
|
||||
mcZeroBits esi
|
||||
ret
|
||||
|
||||
; --------------------------------------------------------------------------
|
||||
; Input:
|
||||
; ESI = ANSI text
|
||||
; AL = character to find
|
||||
; Output:
|
||||
; ECX = character offset (CF=TRUE)
|
||||
; --------------------------------------------------------------------------
|
||||
align PROC_ALIGN
|
||||
TCmdBuf_AnsiFindChar:
|
||||
mcZeroBits ecx
|
||||
|
||||
.test_char:
|
||||
cmp byte [esi + ecx], 0
|
||||
je .not_found
|
||||
|
||||
cmp [esi + ecx], al
|
||||
je .found
|
||||
|
||||
inc ecx
|
||||
jmp .test_char
|
||||
|
||||
.found:
|
||||
stc
|
||||
ret
|
||||
|
||||
.not_found:
|
||||
clc
|
||||
ret
|
||||
|
||||
; --------------------------------------------------------------------------
|
||||
; Output:
|
||||
; EBX = TCmdBuf instance
|
||||
; ESI = ANSI token scanned
|
||||
; --------------------------------------------------------------------------
|
||||
align PROC_ALIGN
|
||||
TCmdBuf_Scan:
|
||||
call TCmdBuf_GetNextToken
|
||||
mcStoreMember TCmdBuf.cmdbuf_KEY, al
|
||||
|
||||
mcZeroBits edx
|
||||
mcStoreMember TCmdBuf.cmdbuf_INUM, edx
|
||||
mcStoreMember TCmdBuf.cmdbuf_AnsiTokenBuf, dl
|
||||
|
||||
fldz
|
||||
fstp [ebx + TCmdBuf.cmdbuf_FNUM]
|
||||
|
||||
mcOnRegZero esi, .done
|
||||
;
|
||||
; Convert the token into ANSI
|
||||
;
|
||||
mcLoadMemberRef edi, TCmdBuf.cmdbuf_AnsiTokenBuf
|
||||
mov eax, edx
|
||||
|
||||
.convert_char:
|
||||
lodsw
|
||||
stosb
|
||||
mcOnRegNotZero eax, .convert_char
|
||||
|
||||
cmp [ebx + TCmdBuf.cmdbuf_KEY], CMD_TOKEN_ALPHA
|
||||
je .done
|
||||
|
||||
mcLoadMemberRef esi, TCmdBuf.cmdbuf_AnsiTokenBuf
|
||||
mov al, '.'
|
||||
call TCmdBuf_AnsiFindChar
|
||||
jc .set_fp_num
|
||||
;
|
||||
; Integer value scanned
|
||||
;
|
||||
call TCmdBuf_AnsiStr2Int32
|
||||
mcStoreMember TCmdBuf.cmdbuf_INUM, eax
|
||||
|
||||
fild [ebx + TCmdBuf.cmdbuf_INUM]
|
||||
fstp [ebx + TCmdBuf.cmdbuf_FNUM]
|
||||
jmp .done
|
||||
|
||||
.set_fp_num:
|
||||
;
|
||||
; FP value scanned
|
||||
;
|
||||
mcLoadMemberRef edi, TCmdBuf.cmdbuf_FNUM
|
||||
call TCmdBuf_AnsiStr2Double
|
||||
|
||||
.done:
|
||||
mcLoadMemberRef esi, TCmdBuf.cmdbuf_AnsiTokenBuf
|
||||
ret
|
||||
|
||||
; --------------------------------------------------------------------------
|
||||
; Input:
|
||||
; ESI = ANSI text
|
||||
; Output:
|
||||
; ECX = number of characters in the string
|
||||
; --------------------------------------------------------------------------
|
||||
align PROC_ALIGN
|
||||
TCmdBuf_AnsiStrLen:
|
||||
push edx
|
||||
|
||||
mcZeroBits ecx
|
||||
mcZeroBits edx
|
||||
|
||||
.check_char:
|
||||
cmp [esi + ecx], dl
|
||||
je .done
|
||||
|
||||
inc ecx
|
||||
jmp .check_char
|
||||
|
||||
.done:
|
||||
pop edx
|
||||
ret
|
||||
|
||||
; --------------------------------------------------------------------------
|
||||
; Input:
|
||||
; ESI = ANSI text
|
||||
; Output:
|
||||
; EAX = converted value
|
||||
; --------------------------------------------------------------------------
|
||||
virtual at 0
|
||||
loc5:
|
||||
.bNegative BOOL ?
|
||||
.size = $
|
||||
end virtual
|
||||
; --------------------------------------------------------------------------
|
||||
align PROC_ALIGN
|
||||
TCmdBuf_AnsiStr2Int32:
|
||||
mcBeginLocals loc5.size
|
||||
|
||||
mcZeroBits eax
|
||||
mcZeroBits edx
|
||||
mcStoreLocal loc5.bNegative, eax
|
||||
|
||||
cmp byte [esi], '-'
|
||||
jne .convert
|
||||
|
||||
inc [esp + loc5.bNegative]
|
||||
inc esi
|
||||
|
||||
.convert:
|
||||
mov dl, [esi]
|
||||
mcOnRegZero edx, .apply_sign
|
||||
|
||||
sub dl, '0'
|
||||
inc esi
|
||||
imul eax, 10
|
||||
add eax, edx
|
||||
jmp .convert
|
||||
|
||||
.apply_sign:
|
||||
cmp byte [esp + loc5.bNegative], 0
|
||||
je .done
|
||||
|
||||
neg eax
|
||||
|
||||
.done:
|
||||
mcEndLocals loc5.size
|
||||
ret
|
||||
|
||||
; --------------------------------------------------------------------------
|
||||
; Input:
|
||||
; ESI = text
|
||||
; EDI = pointer to DOUBLE value
|
||||
; --------------------------------------------------------------------------
|
||||
virtual at 0
|
||||
loc6:
|
||||
.pszDot PCHAR ?
|
||||
.pszValue PCHAR ?
|
||||
.bNegative BOOL ?
|
||||
.iPart1 INT32 ?
|
||||
.iPart2 INT32 ?
|
||||
.pDblResult PDOUBLE ?
|
||||
.dblPart1 DOUBLE ?
|
||||
.dblPart2 DOUBLE ?
|
||||
.size = $
|
||||
end virtual
|
||||
; --------------------------------------------------------------------------
|
||||
align PROC_ALIGN
|
||||
TCmdBuf_AnsiStr2Double:
|
||||
mcBeginLocals loc6.size
|
||||
mcStoreLocal loc6.pszValue, esi
|
||||
mcStoreLocal loc6.pDblResult, edi
|
||||
|
||||
mcZeroBits eax
|
||||
mcStoreLocal loc6.bNegative, eax
|
||||
mcStoreLocal loc6.pszDot, eax
|
||||
|
||||
cmp byte [esi], '-'
|
||||
jne .parse
|
||||
|
||||
inc [esp + loc6.bNegative]
|
||||
inc [esp + loc6.pszValue]
|
||||
inc esi
|
||||
|
||||
.parse:
|
||||
lodsb
|
||||
mcOnRegZero eax, .analysis
|
||||
mcOnRegEqu al, '.', .dot
|
||||
jmp .parse
|
||||
|
||||
.dot:
|
||||
lea edx, [esi - 1]
|
||||
mcStoreLocal loc6.pszDot, edx
|
||||
jmp .parse
|
||||
|
||||
.analysis:
|
||||
cmp byte [esp + loc6.pszDot], 0
|
||||
jne .combine_parts
|
||||
;
|
||||
; No decimal point
|
||||
;
|
||||
mcLoadLocal esi, loc6.pszValue
|
||||
call TCmdBuf_AnsiStr2Int32
|
||||
mcStoreLocal loc6.iPart1, eax
|
||||
|
||||
fild [esp + loc6.iPart1]
|
||||
jmp .apply_sign
|
||||
|
||||
.combine_parts:
|
||||
mcLoadLocal edi, loc6.pszDot
|
||||
mcZeroBits al
|
||||
stosb
|
||||
|
||||
fldz
|
||||
fldz
|
||||
fstp [esp + loc6.dblPart1]
|
||||
fstp [esp + loc6.dblPart2]
|
||||
|
||||
mov esi, edi
|
||||
call TCmdBuf_AnsiStr2Int32
|
||||
mcStoreLocal loc6.iPart2, eax
|
||||
|
||||
mcLoadLocal esi, loc6.pszValue
|
||||
call TCmdBuf_AnsiStr2Int32
|
||||
mcStoreLocal loc6.iPart1, eax
|
||||
|
||||
mcLoadLocal esi, loc6.pszDot
|
||||
inc esi
|
||||
call TCmdBuf_AnsiStrLen
|
||||
jecxz .combine
|
||||
|
||||
fild [esp + loc6.iPart2]
|
||||
@@:
|
||||
fld [glb_dbl_Ten]
|
||||
fdivp
|
||||
loop @r
|
||||
|
||||
fstp [esp + loc6.dblPart2]
|
||||
|
||||
.combine:
|
||||
fild [esp + loc6.iPart1]
|
||||
fld [esp + loc6.dblPart2]
|
||||
faddp
|
||||
|
||||
.apply_sign:
|
||||
cmp byte [esp + loc6.bNegative], 0
|
||||
je .done
|
||||
|
||||
fchs
|
||||
|
||||
.done:
|
||||
mcLoadLocal edi, loc6.pDblResult
|
||||
fstp tbyte [edi]
|
||||
|
||||
mcEndLocals loc6.size
|
||||
ret
|
||||
|
||||
; --------------------------------------------------------------------------
|
||||
; Output:
|
||||
; CF = TRUE if buffer has no characters
|
||||
; --------------------------------------------------------------------------
|
||||
align PROC_ALIGN
|
||||
TCmdBuf_IsEmpty:
|
||||
mov ebx, [glb_pCmdBuf]
|
||||
cmp [ebx + TCmdBuf.cmdbuf_CmdColumn], 0
|
||||
sete cl
|
||||
shr cl, 1
|
||||
ret
|
||||
|
||||
; --------------------------------------------------------------------------
|
||||
align PROC_ALIGN
|
||||
TCmdBuf_Backspace:
|
||||
mov ebx, [glb_pCmdBuf]
|
||||
cmp [ebx + TCmdBuf.cmdbuf_CmdColumn], 0
|
||||
je .done
|
||||
|
||||
dec [ebx + TCmdBuf.cmdbuf_CmdColumn]
|
||||
|
||||
.done:
|
||||
ret
|
||||
|
||||
; --------------------------------------------------------------------------
|
||||
align PROC_ALIGN
|
||||
TCmdBuf_Create:
|
||||
invoke HeapAlloc, [glb_Allocator], HEAP_NO_SERIALIZE, TCmdBuf.size
|
||||
mov [glb_pCmdBuf], eax
|
||||
|
||||
mov edi, eax
|
||||
mcZeroBits eax
|
||||
mov ecx, TCmdBuf.size
|
||||
rep stosb
|
||||
ret
|
||||
|
||||
; --- EOF ---
|
37
programs/games/StarTrek/trunk/TCmdBuf.Inc
Normal file
37
programs/games/StarTrek/trunk/TCmdBuf.Inc
Normal file
@ -0,0 +1,37 @@
|
||||
; --------------------------------------------------------------------------
|
||||
; FILE: TCmdBuf.Inc
|
||||
; DATE: September 27, 2008
|
||||
; --------------------------------------------------------------------------
|
||||
|
||||
CMDBUF_ROOM_CHARS = 64
|
||||
CMDBUF_MAX_CHARS = (CMDBUF_ROOM_CHARS - 1)
|
||||
CMDBUF_MAX_TOKENS = 16
|
||||
|
||||
; --------------------------------------------------------------------------
|
||||
CMD_TOKEN_EOL = 0
|
||||
CMD_TOKEN_REAL = 1
|
||||
CMD_TOKEN_ALPHA = 2
|
||||
CMD_TOKEN_ERROR = 3
|
||||
|
||||
; --------------------------------------------------------------------------
|
||||
virtual at 0
|
||||
TCmdBuf:
|
||||
.cmdbuf_FullBuffer WCHARS CMDBUF_ROOM_CHARS
|
||||
.cmdbuf_CmdColumn INDEX ?
|
||||
.cmdbuf_CmdTokens STRINGS CMDBUF_MAX_TOKENS
|
||||
.cmdbuf_NumTokens COUNT ?
|
||||
.cmdbuf_TokenIterator INDEX ?
|
||||
.cmdbuf_AnsiTokenBuf CHARS CMDBUF_ROOM_CHARS
|
||||
;
|
||||
; If scanned token is of type CMD_TOKEN_REAL
|
||||
; then following section is filled, otherwise
|
||||
; all following members are set to zero
|
||||
;
|
||||
.cmdbuf_INUM INT32 ?
|
||||
.cmdbuf_FNUM DOUBLE ?
|
||||
.cmdbuf_KEY BYTE ?
|
||||
.cmdbuf_Reserved BYTE ?
|
||||
.size = $
|
||||
end virtual
|
||||
|
||||
; --- EOF ---
|
1644
programs/games/StarTrek/trunk/TCommon.Asm
Normal file
1644
programs/games/StarTrek/trunk/TCommon.Asm
Normal file
File diff suppressed because it is too large
Load Diff
185
programs/games/StarTrek/trunk/TCommon.Inc
Normal file
185
programs/games/StarTrek/trunk/TCommon.Inc
Normal file
@ -0,0 +1,185 @@
|
||||
; --------------------------------------------------------------------------
|
||||
; FILE: TCommon.Inc
|
||||
; DATE: October 4, 2008
|
||||
; --------------------------------------------------------------------------
|
||||
|
||||
DEV_SR_SENSORS = 1
|
||||
DEV_LR_SENSORS = 2
|
||||
DEV_PHASERS = 3
|
||||
DEV_PHOTON_TUBES = 4
|
||||
DEV_LIFE_SUPPORT = 5
|
||||
DEV_WARP_ENGINES = 6
|
||||
DEV_IMPULSE_ENGINES = 7
|
||||
DEV_SHIELDS = 8
|
||||
DEV_SUBSPACE_RADIO = 9
|
||||
DEV_SHUTTLE_CRAFT = 10
|
||||
DEV_COMPUTER = 11
|
||||
DEV_TRANSPORTER = 12
|
||||
DEV_SHIELD_CONTROL = 13
|
||||
DEV_DEATHRAY = 14
|
||||
|
||||
CONDITION_GREEN = 1
|
||||
CONDITION_RED = 2
|
||||
CONDITION_YELLOW = 3
|
||||
CONDITION_DOCKED = 4
|
||||
|
||||
virtual at 0
|
||||
TPlanet:
|
||||
.planet_X BYTE ?
|
||||
.planet_Y BYTE ?
|
||||
.planet_CLASS BYTE ?
|
||||
.planet_DILITHIUM BYTE ?
|
||||
.planet_SCANNED BYTE ?
|
||||
.size = $
|
||||
end virtual
|
||||
|
||||
virtual at 0
|
||||
TREKDATA:
|
||||
.CRYPROB DOUBLE ?
|
||||
.DATE DOUBLE ?
|
||||
.REMRES DOUBLE ?
|
||||
.REMTIME DOUBLE ?
|
||||
.KPOWER DOUBLES 20
|
||||
.KDIST DOUBLES 20
|
||||
.DAMAGE DOUBLES 14
|
||||
.INRESOR DOUBLE ?
|
||||
.INTIME DOUBLE ?
|
||||
.INENRG DOUBLE ?
|
||||
.INSHLD DOUBLE ?
|
||||
.INLSR DOUBLE ?
|
||||
.INDATE DOUBLE ?
|
||||
.ENERGY DOUBLE ?
|
||||
.SHLD DOUBLE ?
|
||||
.WARPFAC DOUBLE ?
|
||||
.WFACSQ DOUBLE ?
|
||||
.LSUPRES DOUBLE ?
|
||||
.DIST DOUBLE ?
|
||||
.DIREC DOUBLE ?
|
||||
.TIME DOUBLE ?
|
||||
.DOCKDATE DOUBLE ?
|
||||
.DAMFAC DOUBLE ?
|
||||
.FUTURE1 DOUBLE ?
|
||||
.FUTURE2 DOUBLE ?
|
||||
.FUTURE3 DOUBLE ?
|
||||
.FUTURE4 DOUBLE ?
|
||||
.FUTURE5 DOUBLE ?
|
||||
.FUTURE6 DOUBLE ?
|
||||
.FUTURE7 DOUBLE ?
|
||||
.HEIGHT DOUBLE ?
|
||||
;
|
||||
; Integer variables
|
||||
;
|
||||
align 4
|
||||
.GALAXY INTEGERS 64
|
||||
.STARCH INTEGERS 64
|
||||
.INSTAR INT32 ?
|
||||
.REMKL BYTE ?
|
||||
.REMCOM BYTE ?
|
||||
.REMBASE BYTE ?
|
||||
.STARKL BYTE ?
|
||||
.BASEKL BYTE ?
|
||||
.KILLK BYTE ?
|
||||
.KILLC BYTE ?
|
||||
.CX BYTES 10
|
||||
.CY BYTES 10
|
||||
.BASEQX BYTES 5
|
||||
.BASEQY BYTES 5
|
||||
.NEWSTUF BYTES 64
|
||||
.SCANNED BYTES 64
|
||||
.PLNETS BYTES (10 * TPlanet.size)
|
||||
.ISX BYTE ?
|
||||
.ISY BYTE ?
|
||||
.KSTUF4 BYTE ?
|
||||
.KSTUF5 BYTE ?
|
||||
.NSCREM BYTE ?
|
||||
.NROMKL BYTE ?
|
||||
.NROMREM BYTE ?
|
||||
.NSCKILL BYTE ?
|
||||
.ICRYSTL BYTE ?
|
||||
.NPLANKL BYTE ?
|
||||
.QUAD BYTES 100
|
||||
.KX BYTES 20
|
||||
.KY BYTES 20
|
||||
.INKLING BYTE ?
|
||||
.INBASE BYTE ?
|
||||
.INCOM BYTE ?
|
||||
.INTORPS BYTE ?
|
||||
.SHLDUP BYTE ?
|
||||
.CONDIT BYTE ?
|
||||
.TORPS BYTE ?
|
||||
.SHIP BYTE ?
|
||||
.QUADX BYTE ?
|
||||
.QUADY BYTE ?
|
||||
.SECTX BYTE ?
|
||||
.SECTY BYTE ?
|
||||
.ITHX BYTE ?
|
||||
.ITHY BYTE ?
|
||||
.ITHERE BYTE ?
|
||||
.LENGTH BYTE ?
|
||||
.SKILL BYTE ?
|
||||
.QTORPS BYTE ?
|
||||
.NPTUBES BYTE ?
|
||||
.PASSWD CHARS 12
|
||||
.BASEX BYTE ?
|
||||
.BASEY BYTE ?
|
||||
.KLHERE BYTE ?
|
||||
.COMHERE BYTE ?
|
||||
.CASUAL BYTE ?
|
||||
.NHELP BYTE ?
|
||||
.NKINKS BYTE ?
|
||||
.IDIDIT BYTE ?
|
||||
.KDIDIT BYTE ?
|
||||
.KSHOT BYTE ?
|
||||
.GAMEWON BYTE ?
|
||||
.ALIVE BYTE ?
|
||||
.JUSTIN BYTE ?
|
||||
.RESTING BYTE ?
|
||||
.ALLDONE BYTE ?
|
||||
.SHLDCHG BYTE ?
|
||||
.THINGX BYTE ?
|
||||
.THINGY BYTE ?
|
||||
.PLNETX BYTE ?
|
||||
.PLNETY BYTE ?
|
||||
.INORBIT BYTE ?
|
||||
.LANDED BYTE ?
|
||||
.IPLANET BYTE ?
|
||||
.IMINE BYTE ?
|
||||
.INPLAN BYTE ?
|
||||
.NENHERE BYTE ?
|
||||
.ISHERE BYTE ?
|
||||
.NEUTZ BYTE ?
|
||||
.IRHERE BYTE ?
|
||||
.ICRAFT BYTE ?
|
||||
.IENTESC BYTE ?
|
||||
.ISCRAFT BYTE ?
|
||||
.ISATB BYTE ?
|
||||
.ISCATE BYTE ?
|
||||
.IPHWHO BYTE ?
|
||||
.BATX BYTE ?
|
||||
.BATY BYTE ?
|
||||
.ICSOS BYTE ?
|
||||
.ISSOS BYTE ?
|
||||
.ISUBDAM BYTE ?
|
||||
.SHUTUP BYTE ?
|
||||
.size = $
|
||||
end virtual
|
||||
|
||||
virtual at 0
|
||||
TCommon:
|
||||
.SNAP BYTE ?
|
||||
.SNAPSHT BYTES TREKDATA.size
|
||||
|
||||
align 16
|
||||
.GAMEDB BYTES TREKDATA.size
|
||||
.size = $
|
||||
end virtual
|
||||
|
||||
macro mcLoadGameDataPtr r32
|
||||
{
|
||||
mov r32, [glb_pGameData]
|
||||
}
|
||||
|
||||
PTCommon equ dd
|
||||
PTGameData equ dd
|
||||
|
||||
; --- EOF ---
|
839
programs/games/StarTrek/trunk/TConsole.Asm
Normal file
839
programs/games/StarTrek/trunk/TConsole.Asm
Normal file
@ -0,0 +1,839 @@
|
||||
; --------------------------------------------------------------------------
|
||||
; FILE: TConsole.Asm
|
||||
; DATE: September 21, 2008
|
||||
; --------------------------------------------------------------------------
|
||||
|
||||
; --------------------------------------------------------------------------
|
||||
; CRAM3AS
|
||||
; --------------------------------------------------------------------------
|
||||
align PROC_ALIGN
|
||||
TConsole_Cram3Asterisks:
|
||||
mcLoad8bitsToReg32 ecx, 181
|
||||
call TConsole_Cram
|
||||
ret
|
||||
|
||||
; --------------------------------------------------------------------------
|
||||
; CRAMSHP
|
||||
; --------------------------------------------------------------------------
|
||||
align PROC_ALIGN
|
||||
TConsole_CramShip:
|
||||
mcLoadGameDataPtr ebx
|
||||
mcLoadMember al, TREKDATA.SHIP
|
||||
|
||||
mcOnRegEqu al, CHAR_ENTERPRISE, .good_ship
|
||||
mcOnRegEqu al, CHAR_FQUEENE, .crappy_ship
|
||||
ret
|
||||
|
||||
.good_ship:
|
||||
push 144
|
||||
jmp .dump
|
||||
|
||||
.crappy_ship:
|
||||
push 145
|
||||
|
||||
.dump:
|
||||
pop ecx
|
||||
call TConsole_Cram
|
||||
ret
|
||||
|
||||
; --------------------------------------------------------------------------
|
||||
align PROC_ALIGN
|
||||
TConsole_ScrollUp:
|
||||
pushad
|
||||
|
||||
mov ebx, [glb_pConsole]
|
||||
mov edi, ebx
|
||||
lea esi, [edi + TLine.size]
|
||||
mov ecx, TConsole.cons_LastRow
|
||||
rep movsb
|
||||
|
||||
lea edi, [ebx + TConsole.cons_LastRow]
|
||||
mcZeroBits eax
|
||||
mov ecx, TLine.size
|
||||
rep stosb
|
||||
|
||||
mcStoreMember TConsole.cons_CaretColumn, eax
|
||||
|
||||
mov esi, eax
|
||||
call TApp_RefreshMainWndRect
|
||||
|
||||
mov al, 0Dh
|
||||
call TLog_DumpChar
|
||||
mov al, 0Ah
|
||||
call TLog_DumpChar
|
||||
|
||||
popad
|
||||
ret
|
||||
|
||||
; --------------------------------------------------------------------------
|
||||
align PROC_ALIGN
|
||||
TConsole_RefreshCaretLine:
|
||||
mcBeginLocals RECT.size
|
||||
|
||||
mov esi, esp
|
||||
invoke GetClientRect, [glb_MainWnd], esi
|
||||
|
||||
mov eax, [esi + RECT.rc_Bottom]
|
||||
sub eax, dword [glb_CharSize + SIZE.size_Height]
|
||||
dec eax
|
||||
mov [esi + RECT.rc_Top], eax
|
||||
|
||||
call TApp_RefreshMainWndRect
|
||||
|
||||
mcEndLocals RECT.size
|
||||
ret
|
||||
|
||||
; --------------------------------------------------------------------------
|
||||
align PROC_ALIGN
|
||||
TConsole_Backspace:
|
||||
mov ebx, [glb_pConsole]
|
||||
cmp [ebx + TConsole.cons_CaretColumn], 0
|
||||
je .done
|
||||
|
||||
dec [ebx + TConsole.cons_CaretColumn]
|
||||
mcZeroBits eax
|
||||
call TConsole_PutChar
|
||||
|
||||
dec [ebx + TConsole.cons_CaretColumn]
|
||||
call TConsole_RefreshCaretLine
|
||||
|
||||
.done:
|
||||
ret
|
||||
|
||||
; --------------------------------------------------------------------------
|
||||
; Input:
|
||||
; AL = character code
|
||||
; --------------------------------------------------------------------------
|
||||
align PROC_ALIGN
|
||||
TConsole_PutChar:
|
||||
mov ebx, [glb_pConsole]
|
||||
cmp [ebx + TConsole.cons_CaretColumn], CONSOLE_LAST_COL
|
||||
jae .done
|
||||
|
||||
mcLoadMember ecx, TConsole.cons_CaretColumn
|
||||
inc [ebx + TConsole.cons_CaretColumn]
|
||||
imul ecx, TCharacter.size
|
||||
lea edi, [ebx + ecx + TConsole.cons_LastRow]
|
||||
|
||||
mcLoadMember edx, TConsole.cons_ActiveColor
|
||||
mov [edi + TCharacter.char_Symbol], al
|
||||
mov [edi + TCharacter.char_Attribute], dl
|
||||
|
||||
pushad
|
||||
call TLog_DumpChar
|
||||
popad
|
||||
|
||||
.done:
|
||||
ret
|
||||
|
||||
; --------------------------------------------------------------------------
|
||||
; Input:
|
||||
; CL = index of color
|
||||
; --------------------------------------------------------------------------
|
||||
align PROC_ALIGN
|
||||
TConsole_SetAttr:
|
||||
cmp cl, CONSOLE_ATTRS
|
||||
jae .done
|
||||
|
||||
and ecx, 0FFh
|
||||
push ebx
|
||||
mov ebx, [glb_pConsole]
|
||||
mcStoreMember TConsole.cons_ActiveColor, ecx
|
||||
pop ebx
|
||||
|
||||
.done:
|
||||
ret
|
||||
|
||||
; --------------------------------------------------------------------------
|
||||
align PROC_ALIGN
|
||||
TConsole_SetGameMsgAttr:
|
||||
mov cl, ATTR_GAME_MSG
|
||||
call TConsole_SetAttr
|
||||
ret
|
||||
|
||||
; --------------------------------------------------------------------------
|
||||
align PROC_ALIGN
|
||||
TConsole_SetCrewMsgAttr:
|
||||
mov cl, ATTR_CREW_MSG
|
||||
call TConsole_SetAttr
|
||||
ret
|
||||
|
||||
; --------------------------------------------------------------------------
|
||||
; Input:
|
||||
; AL = character code
|
||||
; CL = number of characters
|
||||
; --------------------------------------------------------------------------
|
||||
align PROC_ALIGN
|
||||
TConsole_RepeatChar:
|
||||
and ecx, 0FFh
|
||||
|
||||
.next:
|
||||
push ecx
|
||||
call TConsole_PutChar
|
||||
pop ecx
|
||||
loop .next
|
||||
ret
|
||||
|
||||
; --------------------------------------------------------------------------
|
||||
; Input:
|
||||
; CL = number of characters
|
||||
; --------------------------------------------------------------------------
|
||||
align PROC_ALIGN
|
||||
TConsole_RepeatBlank:
|
||||
mov al, CHAR_BLANK
|
||||
call TConsole_RepeatChar
|
||||
ret
|
||||
|
||||
; --------------------------------------------------------------------------
|
||||
; Input:
|
||||
; CL = number of characters
|
||||
; --------------------------------------------------------------------------
|
||||
align PROC_ALIGN
|
||||
TConsole_RepeatAsterisk:
|
||||
mov al, CHAR_ASTERISK
|
||||
call TConsole_RepeatChar
|
||||
ret
|
||||
|
||||
; --------------------------------------------------------------------------
|
||||
; SUBROUTINE CRAM from original FORTRAN source
|
||||
; --------------------------------------------------------------------------
|
||||
; Input:
|
||||
; ECX = index of the message table
|
||||
; --------------------------------------------------------------------------
|
||||
align PROC_ALIGN
|
||||
TConsole_Cram:
|
||||
call TMsgTable_GetItem
|
||||
mcZeroBits eax
|
||||
|
||||
.get_char:
|
||||
lodsb
|
||||
mcOnRegZero eax, .done
|
||||
|
||||
call TConsole_PutChar
|
||||
jmp .get_char
|
||||
|
||||
.done:
|
||||
ret
|
||||
|
||||
; --------------------------------------------------------------------------
|
||||
; Input:
|
||||
; ESI = UNICODE text
|
||||
; --------------------------------------------------------------------------
|
||||
align PROC_ALIGN
|
||||
TConsole_CramWide:
|
||||
mcZeroBits eax
|
||||
|
||||
.get_char:
|
||||
lodsw
|
||||
mcOnRegZero eax, .done
|
||||
|
||||
call TConsole_PutChar
|
||||
jmp .get_char
|
||||
|
||||
.done:
|
||||
ret
|
||||
|
||||
; --------------------------------------------------------------------------
|
||||
; Input:
|
||||
; ESI = ANSI text
|
||||
; --------------------------------------------------------------------------
|
||||
align PROC_ALIGN
|
||||
TConsole_CramAnsi:
|
||||
mcZeroBits eax
|
||||
|
||||
.get_char:
|
||||
lodsb
|
||||
mcOnRegZero eax, .done
|
||||
|
||||
call TConsole_PutChar
|
||||
jmp .get_char
|
||||
|
||||
.done:
|
||||
ret
|
||||
|
||||
; --------------------------------------------------------------------------
|
||||
; Input:
|
||||
; ECX = index of the message table
|
||||
; DL = field width
|
||||
; --------------------------------------------------------------------------
|
||||
align PROC_ALIGN
|
||||
TConsole_CramString:
|
||||
movzx edx, dl
|
||||
call TMsgTable_GetLength
|
||||
|
||||
cmp eax, edx
|
||||
jae .cram_and_exit
|
||||
|
||||
sub edx, eax
|
||||
push edx
|
||||
call TConsole_Cram
|
||||
|
||||
pop ecx
|
||||
call TConsole_RepeatBlank
|
||||
ret
|
||||
|
||||
.cram_and_exit:
|
||||
call TConsole_Cram
|
||||
ret
|
||||
|
||||
; --------------------------------------------------------------------------
|
||||
; Input:
|
||||
; CL = 1-based device index (like DEV_IMPULSE_ENGINES)
|
||||
; --------------------------------------------------------------------------
|
||||
align PROC_ALIGN
|
||||
TConsole_CramDevice:
|
||||
movzx ecx, cl
|
||||
add ecx, 59
|
||||
call TConsole_Cram
|
||||
ret
|
||||
|
||||
; --------------------------------------------------------------------------
|
||||
; CRAMEN
|
||||
; --------------------------------------------------------------------------
|
||||
; Input:
|
||||
; AL = object symbol
|
||||
; --------------------------------------------------------------------------
|
||||
align PROC_ALIGN
|
||||
TConsole_CramEnemy:
|
||||
pushad
|
||||
|
||||
mov edi, glb_ObjectMap
|
||||
mcLoad8bitsToReg32 ecx, 9
|
||||
mov edx, edi
|
||||
repne scasb
|
||||
jne .done
|
||||
|
||||
.cram_it:
|
||||
sub edi, edx
|
||||
lea ecx, [edi + 202]
|
||||
call TConsole_Cram
|
||||
|
||||
.done:
|
||||
popad
|
||||
ret
|
||||
|
||||
; --------------------------------------------------------------------------
|
||||
; CRMSENA
|
||||
; --------------------------------------------------------------------------
|
||||
; Input:
|
||||
; AL = X coordinate
|
||||
; DL = Y coordinate
|
||||
; CL = 1 for "QUADRANT", 2 for "SECTOR", 0 for none
|
||||
; BL = Enemy character
|
||||
; --------------------------------------------------------------------------
|
||||
align PROC_ALIGN
|
||||
TConsole_CramEnemyAt:
|
||||
push eax ecx edx
|
||||
|
||||
mov al, bl
|
||||
call TConsole_CramEnemy
|
||||
|
||||
mov ecx, 257
|
||||
call TConsole_Cram
|
||||
|
||||
pop edx ecx eax
|
||||
call TConsole_CramLoc
|
||||
ret
|
||||
|
||||
; --------------------------------------------------------------------------
|
||||
; Input:
|
||||
; AL = sector X coordinate
|
||||
; DL = sector Y coordinate
|
||||
; --------------------------------------------------------------------------
|
||||
align PROC_ALIGN
|
||||
TConsole_CramEnemyAtEx:
|
||||
push ebx
|
||||
call TArray_QuadPtr
|
||||
mov bl, [ebx]
|
||||
mov cl, 2
|
||||
call TConsole_CramEnemyAt
|
||||
pop ebx
|
||||
ret
|
||||
|
||||
; --------------------------------------------------------------------------
|
||||
; Input:
|
||||
; EAX = Int32 value to print
|
||||
; CL = field width or zero (value is padded with blanks on the left side)
|
||||
; --------------------------------------------------------------------------
|
||||
virtual at 0
|
||||
loc19:
|
||||
.bufInt32 CHARS 12
|
||||
.nWidth COUNT ?
|
||||
.size = $
|
||||
end virtual
|
||||
; --------------------------------------------------------------------------
|
||||
align PROC_ALIGN
|
||||
TConsole_CramIntWidth:
|
||||
mcBeginLocals loc19.size
|
||||
|
||||
movzx ecx, cl
|
||||
mcStoreLocal loc19.nWidth, ecx
|
||||
|
||||
mcLoadLocalRef edi, loc19.bufInt32
|
||||
call TFormat_Int32
|
||||
|
||||
cmp [esp + loc19.nWidth], 0
|
||||
je .dump
|
||||
|
||||
cmp [esp + loc19.nWidth], ecx
|
||||
jbe .dump
|
||||
|
||||
sub ecx, [esp + loc19.nWidth]
|
||||
neg ecx
|
||||
call TConsole_RepeatBlank
|
||||
|
||||
.dump:
|
||||
mcLoadLocalRef esi, loc19.bufInt32
|
||||
mcZeroBits eax
|
||||
|
||||
.next:
|
||||
lodsb
|
||||
mcOnRegZero eax, .done
|
||||
call TConsole_PutChar
|
||||
jmp .next
|
||||
|
||||
.done:
|
||||
mcEndLocals loc19.size
|
||||
ret
|
||||
|
||||
; --------------------------------------------------------------------------
|
||||
; Input:
|
||||
; EAX = Int32 value to print
|
||||
; --------------------------------------------------------------------------
|
||||
align PROC_ALIGN
|
||||
TConsole_CramInt:
|
||||
pushad
|
||||
mcZeroBits ecx
|
||||
call TConsole_CramIntWidth
|
||||
popad
|
||||
ret
|
||||
|
||||
; --------------------------------------------------------------------------
|
||||
; Input:
|
||||
; ECX = message table index
|
||||
; EAX = Int32 value to print
|
||||
; --------------------------------------------------------------------------
|
||||
align PROC_ALIGN
|
||||
TConsole_CramSinglePlural:
|
||||
push eax ecx
|
||||
call TConsole_CramInt
|
||||
|
||||
mov al, CHAR_BLANK
|
||||
call TConsole_PutChar
|
||||
|
||||
pop ecx
|
||||
call TConsole_Cram
|
||||
|
||||
pop eax
|
||||
cmp al, 1
|
||||
je .done
|
||||
|
||||
mov al, 'S'
|
||||
call TConsole_PutChar
|
||||
|
||||
.done:
|
||||
ret
|
||||
|
||||
; --------------------------------------------------------------------------
|
||||
; Input:
|
||||
; AL = X coordinate
|
||||
; DL = Y coordinate
|
||||
; CL = KEY (1 - print "QUADRANT", 2 - print "SECTOR")
|
||||
; --------------------------------------------------------------------------
|
||||
virtual at 0
|
||||
loc21:
|
||||
.nIX INT32 ?
|
||||
.nIY INT32 ?
|
||||
.size = $
|
||||
end virtual
|
||||
; --------------------------------------------------------------------------
|
||||
align PROC_ALIGN
|
||||
TConsole_CramLoc:
|
||||
mcBeginLocals loc21.size
|
||||
|
||||
movzx eax, al
|
||||
movzx edx, dl
|
||||
mcStoreLocal loc21.nIX, eax
|
||||
mcStoreLocal loc21.nIY, edx
|
||||
|
||||
mcOnRegZero cl, .print_values
|
||||
|
||||
add cl, 56
|
||||
movzx ecx, cl
|
||||
call TConsole_Cram
|
||||
|
||||
.print_values:
|
||||
mov al, CHAR_BLANK
|
||||
call TConsole_PutChar
|
||||
|
||||
mcLoadLocal eax, loc21.nIX
|
||||
call TConsole_CramInt
|
||||
|
||||
mcLoad8bitsToReg32 ecx, 59
|
||||
call TConsole_Cram
|
||||
|
||||
mcLoadLocal eax, loc21.nIY
|
||||
call TConsole_CramInt
|
||||
|
||||
mcEndLocals loc21.size
|
||||
ret
|
||||
|
||||
; --------------------------------------------------------------------------
|
||||
; Input:
|
||||
; ST(0) = value to print
|
||||
; CL = precision
|
||||
; DL = field width or zero
|
||||
; --------------------------------------------------------------------------
|
||||
virtual at 0
|
||||
loc20:
|
||||
.bufDouble CHARS 16
|
||||
.nWidth COUNT ?
|
||||
.size = $
|
||||
end virtual
|
||||
; --------------------------------------------------------------------------
|
||||
align PROC_ALIGN
|
||||
TConsole_CramFloatWidth:
|
||||
mcBeginLocals loc20.size
|
||||
|
||||
movzx edx, dl
|
||||
mcStoreLocal loc20.nWidth, edx
|
||||
|
||||
mcLoadLocalRef edi, loc20.bufDouble
|
||||
call TFormat_Double
|
||||
|
||||
cmp [esp + loc20.nWidth], 0
|
||||
je .dump
|
||||
|
||||
cmp [esp + loc20.nWidth], ecx
|
||||
jbe .dump
|
||||
|
||||
sub ecx, [esp + loc20.nWidth]
|
||||
neg ecx
|
||||
call TConsole_RepeatBlank
|
||||
|
||||
.dump:
|
||||
mcLoadLocalRef esi, loc20.bufDouble
|
||||
mcZeroBits eax
|
||||
|
||||
.next:
|
||||
lodsb
|
||||
mcOnRegZero eax, .done
|
||||
call TConsole_PutChar
|
||||
jmp .next
|
||||
|
||||
.done:
|
||||
mcEndLocals loc20.size
|
||||
ret
|
||||
|
||||
; --------------------------------------------------------------------------
|
||||
; Input:
|
||||
; ST(0) = value to print
|
||||
; CL = precision
|
||||
; --------------------------------------------------------------------------
|
||||
align PROC_ALIGN
|
||||
TConsole_CramFloat:
|
||||
pushad
|
||||
mcZeroBits edx
|
||||
call TConsole_CramFloatWidth
|
||||
popad
|
||||
ret
|
||||
|
||||
; --------------------------------------------------------------------------
|
||||
; SUBROUTINE PROUT from original FORTRAN source
|
||||
; --------------------------------------------------------------------------
|
||||
; Input:
|
||||
; ECX = index of the message table
|
||||
; --------------------------------------------------------------------------
|
||||
align PROC_ALIGN
|
||||
TConsole_Prout:
|
||||
push ecx
|
||||
call TConsole_Cram
|
||||
call TConsole_ScrollUp
|
||||
pop ecx
|
||||
ret
|
||||
|
||||
; --------------------------------------------------------------------------
|
||||
; Input:
|
||||
; CL = number of lines to skip
|
||||
; --------------------------------------------------------------------------
|
||||
align PROC_ALIGN
|
||||
TConsole_Skip:
|
||||
movzx ecx, cl
|
||||
|
||||
.skipping:
|
||||
push ecx
|
||||
call TConsole_ScrollUp
|
||||
pop ecx
|
||||
loop .skipping
|
||||
ret
|
||||
|
||||
; --------------------------------------------------------------------------
|
||||
; Input:
|
||||
; ECX = index of the message table
|
||||
; --------------------------------------------------------------------------
|
||||
align PROC_ALIGN
|
||||
TConsole_ProutGameMsg:
|
||||
push ecx
|
||||
call TConsole_SetGameMsgAttr
|
||||
pop ecx
|
||||
call TConsole_Prout
|
||||
ret
|
||||
|
||||
; --------------------------------------------------------------------------
|
||||
; Input:
|
||||
; CL = index of color
|
||||
; Output:
|
||||
; EAX = COLORREF at the specified index
|
||||
; --------------------------------------------------------------------------
|
||||
align PROC_ALIGN
|
||||
TConsole_GetColorAtIndex:
|
||||
mcLoadRGB eax, 255, 0, 0
|
||||
cmp cl, CONSOLE_ATTRS
|
||||
jae .done
|
||||
|
||||
and ecx, 0FFh
|
||||
mov ebx, [glb_pConsole]
|
||||
mov eax, [ebx + 4*ecx + TConsole.cons_Attributes]
|
||||
|
||||
.done:
|
||||
ret
|
||||
|
||||
; --------------------------------------------------------------------------
|
||||
; Input:
|
||||
; EDX = HDC
|
||||
; EAX = Y coordinate
|
||||
; ESI = address of TLine structure
|
||||
; ECX = number of lines left in the loop
|
||||
; --------------------------------------------------------------------------
|
||||
virtual at 0
|
||||
loc2:
|
||||
.hDC HDC ?
|
||||
.yText INT32 ?
|
||||
.xText INT32 ?
|
||||
.pTChar PTCharacter ?
|
||||
.rgbNow COLORREF ?
|
||||
.strOneChar WCHARS 2
|
||||
.nLinesLeft COUNT ?
|
||||
.rect_Caret rb RECT.size
|
||||
.size = $
|
||||
end virtual
|
||||
; --------------------------------------------------------------------------
|
||||
align PROC_ALIGN
|
||||
TConsole_DrawLine:
|
||||
mcBeginLocals loc2.size
|
||||
|
||||
mcStoreLocal loc2.nLinesLeft, ecx
|
||||
mcStoreLocal loc2.hDC, edx
|
||||
mcStoreLocal loc2.yText, eax
|
||||
mcStoreLocal loc2.pTChar, esi
|
||||
|
||||
mcZeroBits eax
|
||||
mcStoreLocal loc2.rgbNow, eax
|
||||
inc eax
|
||||
mcStoreLocal loc2.xText, eax
|
||||
|
||||
.load_char:
|
||||
mcLoadLocal esi, loc2.pTChar
|
||||
cmp [esi + TCharacter.char_Symbol], 0
|
||||
je .draw_caret
|
||||
|
||||
movzx eax, [esi + TCharacter.char_Symbol]
|
||||
mov [esp + loc2.strOneChar], ax
|
||||
|
||||
mov cl, [esi + TCharacter.char_Attribute]
|
||||
call TConsole_GetColorAtIndex
|
||||
|
||||
mcLoadLocal edi, loc2.hDC
|
||||
cmp [esp + loc2.rgbNow], eax
|
||||
je .draw_char
|
||||
|
||||
mcStoreLocal loc2.rgbNow, eax
|
||||
invoke SetTextColor, edi, eax
|
||||
|
||||
.draw_char:
|
||||
mov ebx, esp
|
||||
lea esi, [ebx + loc2.strOneChar]
|
||||
|
||||
invoke TextOut, edi, \
|
||||
[ebx + loc2.xText], \
|
||||
[ebx + loc2.yText], esi, 1
|
||||
|
||||
add [ebx + loc2.pTChar], TCharacter.size
|
||||
|
||||
mov eax, dword [glb_CharSize + SIZE.size_Width]
|
||||
add [ebx + loc2.xText], eax
|
||||
jmp .load_char
|
||||
|
||||
.draw_caret:
|
||||
cmp [esp + loc2.nLinesLeft], 1
|
||||
jne .done
|
||||
;
|
||||
; Paint a rectangular caret
|
||||
;
|
||||
mov ebx, esp
|
||||
mcLoadMemberRef edi, loc2.rect_Caret
|
||||
mcLoadMember edx, loc2.xText
|
||||
mcLoadMember eax, loc2.yText
|
||||
mov [edi + RECT.rc_Left], edx
|
||||
mov [edi + RECT.rc_Top], eax
|
||||
|
||||
mov esi, glb_CharSize
|
||||
add edx, [esi + SIZE.size_Width]
|
||||
add eax, [esi + SIZE.size_Height]
|
||||
mov [edi + RECT.rc_Right], edx
|
||||
mov [edi + RECT.rc_Bottom], eax
|
||||
|
||||
mov cl, ATTR_PROMPT_VALUE
|
||||
call TConsole_GetColorAtIndex
|
||||
|
||||
invoke CreateSolidBrush, eax
|
||||
mov esi, eax
|
||||
mcLoadLocal edx, loc2.hDC
|
||||
mcLoadLocalRef edi, loc2.rect_Caret
|
||||
inc [edi + RECT.rc_Left]
|
||||
inc [edi + RECT.rc_Right]
|
||||
invoke FillRect, edx, edi, eax
|
||||
invoke DeleteObject, esi
|
||||
|
||||
.done:
|
||||
mcEndLocals loc2.size
|
||||
ret
|
||||
|
||||
; --------------------------------------------------------------------------
|
||||
; Input:
|
||||
; EDX = HDC
|
||||
; --------------------------------------------------------------------------
|
||||
virtual at 0
|
||||
loc3:
|
||||
.hDC HDC ?
|
||||
.yText INT32 ?
|
||||
.pLineOfChars PTLine ?
|
||||
.nLines COUNT ?
|
||||
.size = $
|
||||
end virtual
|
||||
; --------------------------------------------------------------------------
|
||||
align PROC_ALIGN
|
||||
TConsole_DrawAllLines:
|
||||
mcBeginLocals loc3.size
|
||||
|
||||
mcStoreLocal loc3.hDC, edx
|
||||
|
||||
mcLoad1 eax
|
||||
mcStoreLocal loc3.yText, eax
|
||||
|
||||
mov ebx, [glb_pConsole]
|
||||
mcStoreLocal loc3.pLineOfChars, ebx
|
||||
|
||||
mcLoad8bitsToReg32 ecx, CONSOLE_ROWS
|
||||
mcStoreLocal loc3.nLines, ecx
|
||||
|
||||
.paint_row:
|
||||
mcLoadLocal edx, loc3.hDC
|
||||
mcLoadLocal eax, loc3.yText
|
||||
mcLoadLocal esi, loc3.pLineOfChars
|
||||
mcLoadLocal ecx, loc3.nLines
|
||||
call TConsole_DrawLine
|
||||
|
||||
add [esp + loc3.pLineOfChars], TLine.size
|
||||
|
||||
mov eax, dword [glb_CharSize + SIZE.size_Height]
|
||||
add [esp + loc3.yText], eax
|
||||
|
||||
dec [esp + loc3.nLines]
|
||||
jnz .paint_row
|
||||
|
||||
mcEndLocals loc3.size
|
||||
ret
|
||||
|
||||
; --------------------------------------------------------------------------
|
||||
align PROC_ALIGN
|
||||
TConsole_Create:
|
||||
invoke HeapAlloc, [glb_Allocator], HEAP_NO_SERIALIZE, TConsole.size
|
||||
mov [glb_pConsole], eax
|
||||
|
||||
mov edi, eax
|
||||
mov ecx, TConsole.size
|
||||
mcZeroBits eax
|
||||
push edi
|
||||
rep stosb
|
||||
pop esi
|
||||
;
|
||||
; Init palette
|
||||
;
|
||||
lea edi, [esi + TConsole.cons_Attributes]
|
||||
|
||||
mcLoadRGB eax, 128, 191, 255
|
||||
stosd ; ATTR_GAME_MSG
|
||||
|
||||
mcLoadRGB eax, 255, 255, 206
|
||||
stosd ; ATTR_CREW_MSG
|
||||
|
||||
mcLoadRGB eax, 94, 174, 174
|
||||
stosd ; ATTR_KLINGON
|
||||
|
||||
mcLoadRGB eax, 0, 176, 0
|
||||
stosd ; ATTR_ROMULAN
|
||||
|
||||
mcLoadRGB eax, 192, 192, 192
|
||||
stosd ; ATTR_COSMOS
|
||||
|
||||
mcLoadRGB eax, 255, 255, 255
|
||||
stosd ; ATTR_SHIP
|
||||
|
||||
mcLoadRGB eax, 255, 255, 0
|
||||
stosd ; ATTR_STAR
|
||||
|
||||
mcLoadRGB eax, 6, 131, 255
|
||||
stosd ; ATTR_BASE
|
||||
|
||||
mcLoadRGB eax, 128, 128, 64
|
||||
stosd ; ATTR_THOLIAN
|
||||
|
||||
mcLoadRGB eax, 128, 128, 128
|
||||
stosd ; ATTR_BLACK_HOLE
|
||||
|
||||
mcLoadRGB eax, 230, 211, 157
|
||||
stosd ; ATTR_PLANET
|
||||
|
||||
mcLoadRGB eax, 0, 128, 255
|
||||
stosd ; ATTR_REPORT_TEXT
|
||||
|
||||
mcLoadRGB eax, 62, 158, 255
|
||||
stosd ; ATTR_REPORT_VALUE
|
||||
|
||||
mcLoadRGB eax, 248, 108, 41
|
||||
stosd ; ATTR_GALAXY_EDGE
|
||||
|
||||
mcLoadRGB eax, 149, 255, 202
|
||||
stosd ; ATTR_SHIP_QUAD
|
||||
|
||||
mcLoadRGB eax, 174, 194, 247
|
||||
stosd ; ATTR_SCANNED_QUAD
|
||||
|
||||
mcLoadRGB eax, 218, 191, 5
|
||||
stosd ; ATTR_SCAN_SCALE
|
||||
|
||||
mcLoadRGB eax, 255, 170, 170
|
||||
stosd ; ATTR_HIT_DAMAGE
|
||||
|
||||
mcLoadRGB eax, 181, 181, 106
|
||||
stosd ; ATTR_WEB
|
||||
|
||||
mcLoadRGB eax, 46, 170, 43
|
||||
stosd ; ATTR_COND_GREEN
|
||||
|
||||
mcLoadRGB eax, 255, 255, 130
|
||||
stosd ; ATTR_COND_YELLOW
|
||||
|
||||
mcLoadRGB eax, 255, 73, 64
|
||||
stosd ; ATTR_COND_RED
|
||||
|
||||
mcLoadRGB eax, 0, 155, 0
|
||||
stosd ; ATTR_PROMPT_TEXT
|
||||
|
||||
mcLoadRGB eax, 73, 231, 69
|
||||
stosd ; ATTR_PROMPT_VALUE
|
||||
|
||||
ret
|
||||
|
||||
; --- EOF ---
|
63
programs/games/StarTrek/trunk/TConsole.Inc
Normal file
63
programs/games/StarTrek/trunk/TConsole.Inc
Normal file
@ -0,0 +1,63 @@
|
||||
; --------------------------------------------------------------------------
|
||||
; FILE: TConsole.Inc
|
||||
; DATE: September 21, 2008
|
||||
; --------------------------------------------------------------------------
|
||||
|
||||
CONSOLE_ROWS = 40
|
||||
CONSOLE_COLS = 80
|
||||
CONSOLE_ATTRS = 24
|
||||
CONSOLE_LAST_COL = (CONSOLE_COLS - 1)
|
||||
|
||||
; --------------------------------------------------------------------------
|
||||
ATTR_GAME_MSG = 0
|
||||
ATTR_CREW_MSG = 1
|
||||
ATTR_KLINGON = 2
|
||||
ATTR_ROMULAN = 3
|
||||
ATTR_COSMOS = 4
|
||||
ATTR_SHIP = 5
|
||||
ATTR_STAR = 6
|
||||
ATTR_BASE = 7
|
||||
ATTR_THOLIAN = 8
|
||||
ATTR_BLACK_HOLE = 9
|
||||
ATTR_PLANET = 10
|
||||
ATTR_REPORT_TEXT = 11
|
||||
ATTR_REPORT_VALUE = 12
|
||||
ATTR_GALAXY_EDGE = 13
|
||||
ATTR_SHIP_QUAD = 14
|
||||
ATTR_SCANNED_QUAD = 15
|
||||
ATTR_SCAN_SCALE = 16
|
||||
ATTR_HIT_DAMAGE = 17
|
||||
ATTR_WEB = 18
|
||||
ATTR_COND_GREEN = 19
|
||||
ATTR_COND_YELLOW = 20
|
||||
ATTR_COND_RED = 21
|
||||
ATTR_PROMPT_TEXT = 22
|
||||
ATTR_PROMPT_VALUE = 23
|
||||
|
||||
; --------------------------------------------------------------------------
|
||||
virtual at 0
|
||||
TCharacter:
|
||||
.char_Symbol db ?
|
||||
.char_Attribute db ?
|
||||
.size = $
|
||||
end virtual
|
||||
|
||||
; --------------------------------------------------------------------------
|
||||
virtual at 0
|
||||
TLine:
|
||||
.cons_Symbols rb (TCharacter.size * CONSOLE_COLS)
|
||||
.size = $
|
||||
end virtual
|
||||
|
||||
; --------------------------------------------------------------------------
|
||||
virtual at 0
|
||||
TConsole:
|
||||
.cons_Rows rb (TLine.size * (CONSOLE_ROWS - 1))
|
||||
.cons_LastRow rb TLine.size
|
||||
.cons_CaretColumn INDEX ?
|
||||
.cons_ActiveColor INDEX ?
|
||||
.cons_Attributes COLORREFS CONSOLE_ATTRS
|
||||
.size = $
|
||||
end virtual
|
||||
|
||||
; --- EOF ---
|
848
programs/games/StarTrek/trunk/TDock.Asm
Normal file
848
programs/games/StarTrek/trunk/TDock.Asm
Normal file
@ -0,0 +1,848 @@
|
||||
; --------------------------------------------------------------------------
|
||||
; FILE: TDock.Asm
|
||||
; DATE: October 25, 2008
|
||||
; --------------------------------------------------------------------------
|
||||
|
||||
; --------------------------------------------------------------------------
|
||||
; ABANDON
|
||||
; --------------------------------------------------------------------------
|
||||
virtual at 0
|
||||
loc86:
|
||||
.pTrekData PVOID ?
|
||||
.nAttempts COUNT ?
|
||||
.dbl_ShuttleDamage DOUBLE ?
|
||||
.dbl_padding DOUBLE ?
|
||||
.nBaseSectorX INT32 ?
|
||||
.nBaseSectorY INT32 ?
|
||||
.nFQSectorX INT32 ?
|
||||
.nFQSectorY INT32 ?
|
||||
.size = $
|
||||
end virtual
|
||||
; --------------------------------------------------------------------------
|
||||
align PROC_ALIGN
|
||||
TDock_Abandon:
|
||||
mcBeginLocals loc86.size
|
||||
|
||||
mcLoadGameDataPtr esi
|
||||
mcStoreLocal loc86.pTrekData, esi
|
||||
|
||||
mov cl, DEV_SHUTTLE_CRAFT
|
||||
call TArray_GetDblDamage
|
||||
fstp [esp + loc86.dbl_ShuttleDamage]
|
||||
|
||||
fld [esp + loc86.dbl_ShuttleDamage]
|
||||
fldz
|
||||
mc_CMP_ST0_ST1
|
||||
jc .L10
|
||||
jz .L15
|
||||
|
||||
fld [esp + loc86.dbl_ShuttleDamage]
|
||||
fld1
|
||||
fchs
|
||||
mc_CMP_ST0_ST1
|
||||
jz .L6
|
||||
|
||||
mov ecx, 443
|
||||
call TConsole_ProutGameMsg
|
||||
jmp .done
|
||||
|
||||
.L6:
|
||||
mov ecx, 444
|
||||
call TConsole_ProutGameMsg
|
||||
jmp .done
|
||||
|
||||
.L10:
|
||||
mov ecx, 445
|
||||
call TConsole_ProutGameMsg
|
||||
jmp .done
|
||||
|
||||
.L15:
|
||||
mcLoadLocal esi, loc86.pTrekData
|
||||
cmp [esi + TREKDATA.LANDED], 1
|
||||
jne .check1
|
||||
|
||||
.must_be_aboard:
|
||||
mov ecx, 675
|
||||
call TConsole_ProutGameMsg
|
||||
jmp .done
|
||||
|
||||
.check1:
|
||||
cmp [esi + TREKDATA.ICRAFT], 1
|
||||
je .must_be_aboard
|
||||
|
||||
cmp [esi + TREKDATA.ISCRAFT], 1
|
||||
je .L17
|
||||
|
||||
mov ecx, 674
|
||||
call TConsole_ProutGameMsg
|
||||
jmp .done
|
||||
|
||||
.L17:
|
||||
call TConsole_ScrollUp
|
||||
mov cl, ATTR_COND_RED
|
||||
call TConsole_SetAttr
|
||||
mov ecx, 676
|
||||
call TConsole_Prout
|
||||
inc ecx
|
||||
call TConsole_Prout
|
||||
call TConsole_ScrollUp
|
||||
|
||||
invoke Sleep, 800
|
||||
|
||||
mov ecx, 678
|
||||
call TConsole_ProutGameMsg
|
||||
inc ecx
|
||||
call TConsole_Prout
|
||||
inc ecx
|
||||
call TConsole_Prout
|
||||
|
||||
mcLoadLocal esi, loc86.pTrekData
|
||||
cmp [esi + TREKDATA.REMBASE], 0
|
||||
je .finished
|
||||
|
||||
invoke Sleep, 800
|
||||
|
||||
call TConsole_ScrollUp
|
||||
mov ecx, 681
|
||||
call TConsole_Prout
|
||||
inc ecx
|
||||
call TConsole_Prout
|
||||
inc ecx
|
||||
call TConsole_Prout
|
||||
inc ecx
|
||||
call TConsole_Prout
|
||||
inc ecx
|
||||
call TConsole_Prout
|
||||
|
||||
mcLoadLocal esi, loc86.pTrekData
|
||||
mcZeroBits eax
|
||||
mov [esi + TREKDATA.ICRYSTL], al
|
||||
mov [esi + TREKDATA.IMINE], al
|
||||
mov [esi + TREKDATA.ISCATE], al
|
||||
|
||||
movzx edx, [esi + TREKDATA.REMBASE]
|
||||
call TRandom_IRan
|
||||
mov ecx, eax
|
||||
|
||||
mcLoadLocal ebx, loc86.pTrekData
|
||||
mcLoadMemberRef esi, TREKDATA.BASEQX
|
||||
mcLoadMemberRef edi, TREKDATA.BASEQY
|
||||
mov al, [esi + ecx]
|
||||
mov dl, [edi + ecx]
|
||||
mcStoreMember TREKDATA.QUADX, al
|
||||
mcStoreMember TREKDATA.QUADY, dl
|
||||
|
||||
.L40:
|
||||
mov al, 5
|
||||
mcStoreMember TREKDATA.SECTX, al
|
||||
mcStoreMember TREKDATA.SECTY, al
|
||||
|
||||
call TCommon_NewQuad
|
||||
|
||||
mov al, 5
|
||||
mov dl, al
|
||||
call TArray_QuadPtr
|
||||
mov byte [ebx], CHAR_COSMOS
|
||||
;
|
||||
; Three attempts to put F.Q. beside the base
|
||||
;
|
||||
mcLoad8bitsToReg32 eax, 3
|
||||
mcStoreLocal loc86.nAttempts, eax
|
||||
|
||||
mcLoadLocal esi, loc86.pTrekData
|
||||
movzx eax, [esi + TREKDATA.BASEX]
|
||||
movzx edx, [esi + TREKDATA.BASEY]
|
||||
mcStoreLocal loc86.nBaseSectorX, eax
|
||||
mcStoreLocal loc86.nBaseSectorY, edx
|
||||
|
||||
.attempt:
|
||||
mcLoad8bitsToReg32 edx, 3
|
||||
call TRandom_IRan
|
||||
dec eax
|
||||
add eax, [esp + loc86.nBaseSectorX]
|
||||
mcStoreLocal loc86.nFQSectorX, eax
|
||||
call TPhotons_IsValidSector
|
||||
jnc .next_attempt
|
||||
|
||||
mcLoad8bitsToReg32 edx, 3
|
||||
call TRandom_IRan
|
||||
dec eax
|
||||
add eax, [esp + loc86.nBaseSectorY]
|
||||
mcStoreLocal loc86.nFQSectorY, eax
|
||||
call TPhotons_IsValidSector
|
||||
jnc .next_attempt
|
||||
|
||||
mcLoadLocal eax, loc86.nFQSectorX
|
||||
mcLoadLocal edx, loc86.nFQSectorY
|
||||
call TArray_QuadPtr
|
||||
cmp byte [ebx], CHAR_COSMOS
|
||||
je .L60
|
||||
|
||||
.next_attempt:
|
||||
dec [esp + loc86.nAttempts]
|
||||
jnz .attempt
|
||||
jmp .L40
|
||||
|
||||
.L60:
|
||||
mov byte [ebx], CHAR_FQUEENE
|
||||
mcLoadLocal esi, loc86.pTrekData
|
||||
mov [esi + TREKDATA.SHIP], CHAR_FQUEENE
|
||||
mov [esi + TREKDATA.CONDIT], CONDITION_DOCKED
|
||||
|
||||
mcLoadLocal eax, loc86.nFQSectorX
|
||||
mcLoadLocal edx, loc86.nFQSectorY
|
||||
mov [esi + TREKDATA.SECTX], al
|
||||
mov [esi + TREKDATA.SECTY], dl
|
||||
|
||||
lea edi, [esi + TREKDATA.DAMAGE]
|
||||
mcLoad8bitsToReg32 ecx, 14
|
||||
|
||||
.clear_damages:
|
||||
fldz
|
||||
fstp tbyte [edi]
|
||||
add edi, 10
|
||||
loop .clear_damages
|
||||
|
||||
fld [glb_dbl_3000]
|
||||
fld st
|
||||
fstp [esi + TREKDATA.INENRG]
|
||||
fstp [esi + TREKDATA.ENERGY]
|
||||
|
||||
fld [glb_dbl_1250]
|
||||
fld st
|
||||
fstp [esi + TREKDATA.INSHLD]
|
||||
fstp [esi + TREKDATA.SHLD]
|
||||
|
||||
mov al, 6
|
||||
mov [esi + TREKDATA.INTORPS], al
|
||||
mov [esi + TREKDATA.TORPS], al
|
||||
|
||||
fld [glb_dbl_3]
|
||||
fld st
|
||||
fstp [esi + TREKDATA.INLSR]
|
||||
fstp [esi + TREKDATA.LSUPRES]
|
||||
|
||||
mov [esi + TREKDATA.SHLDUP], 0
|
||||
|
||||
fld [glb_dbl_5]
|
||||
fstp [esi + TREKDATA.WARPFAC]
|
||||
|
||||
fld [glb_dbl_25]
|
||||
fstp [esi + TREKDATA.WFACSQ]
|
||||
jmp .done
|
||||
|
||||
.finished:
|
||||
mov al, 9
|
||||
call TFinish_Main
|
||||
|
||||
.done:
|
||||
mcEndLocals loc86.size
|
||||
ret
|
||||
|
||||
; --------------------------------------------------------------------------
|
||||
; DREPORT
|
||||
; --------------------------------------------------------------------------
|
||||
virtual at 0
|
||||
loc38:
|
||||
.nJDAM INT32 ?
|
||||
.pDAMAGE PDOUBLE ?
|
||||
.nL INDEX ?
|
||||
.size = $
|
||||
end virtual
|
||||
; --------------------------------------------------------------------------
|
||||
align PROC_ALIGN
|
||||
TDock_DamageReport:
|
||||
mcBeginLocals loc38.size
|
||||
|
||||
mcZeroBits eax
|
||||
mcStoreLocal loc38.nJDAM, eax
|
||||
|
||||
inc eax
|
||||
mcStoreLocal loc38.nL, eax
|
||||
|
||||
mcLoadGameDataPtr esi
|
||||
add esi, TREKDATA.DAMAGE
|
||||
mcStoreLocal loc38.pDAMAGE, esi
|
||||
|
||||
.check_device:
|
||||
fldz
|
||||
mcLoadLocal ebx, loc38.pDAMAGE
|
||||
fld tbyte [ebx]
|
||||
mc_CMP_ST0_ST1
|
||||
jc .L20
|
||||
jz .L20
|
||||
|
||||
cmp [esp + loc38.nJDAM], 0
|
||||
jne .L10
|
||||
|
||||
mov cl, ATTR_SCAN_SCALE
|
||||
call TConsole_SetAttr
|
||||
call TConsole_ScrollUp
|
||||
mov ecx, 270
|
||||
call TConsole_Prout
|
||||
mov ecx, 271
|
||||
call TConsole_Prout
|
||||
inc [esp + loc38.nJDAM]
|
||||
|
||||
.L10:
|
||||
mov cl, 2
|
||||
call TConsole_RepeatBlank
|
||||
|
||||
mov cl, ATTR_REPORT_TEXT
|
||||
call TConsole_SetAttr
|
||||
|
||||
mov dl, 22
|
||||
mcLoadLocal ecx, loc38.nL
|
||||
add ecx, 59
|
||||
call TConsole_CramString
|
||||
|
||||
mov cl, ATTR_REPORT_VALUE
|
||||
call TConsole_SetAttr
|
||||
|
||||
cmp [esp + loc38.nL], 14
|
||||
je .deathray
|
||||
|
||||
mcLoadLocal esi, loc38.pDAMAGE
|
||||
fld tbyte [esi]
|
||||
fld [glb_dbl_0dot005]
|
||||
faddp
|
||||
mov cl, 2
|
||||
mov dl, 5
|
||||
call TConsole_CramFloatWidth
|
||||
jmp .docked_value
|
||||
|
||||
.deathray:
|
||||
mov ecx, 269
|
||||
call TConsole_Cram
|
||||
|
||||
.docked_value:
|
||||
mcLoadLocal esi, loc38.pDAMAGE
|
||||
fld tbyte [esi]
|
||||
fld [glb_dbl_DOCKFAC]
|
||||
fmulp
|
||||
fld [glb_dbl_0dot005]
|
||||
faddp
|
||||
mov cl, 2
|
||||
mov dl, 10
|
||||
call TConsole_CramFloatWidth
|
||||
call TConsole_ScrollUp
|
||||
|
||||
.L20:
|
||||
;
|
||||
; Next device
|
||||
;
|
||||
add [esp + loc38.pDAMAGE], 10
|
||||
inc [esp + loc38.nL]
|
||||
cmp [esp + loc38.nL], 14
|
||||
jbe .check_device
|
||||
|
||||
cmp [esp + loc38.nJDAM], 0
|
||||
jne .done
|
||||
|
||||
call TConsole_ScrollUp
|
||||
call TConsole_SetGameMsgAttr
|
||||
mov ecx, 268
|
||||
call TConsole_Prout
|
||||
|
||||
.done:
|
||||
call TConsole_ScrollUp
|
||||
mcEndLocals loc38.size
|
||||
ret
|
||||
|
||||
; --------------------------------------------------------------------------
|
||||
; This function will check if sufficient time passed between dockings to
|
||||
; prevent the cheating by docking a few times in a row and getting
|
||||
; additional photon tubes, quantum charges, etc.
|
||||
; --------------------------------------------------------------------------
|
||||
; Returns CF=1 if additional devices are allowed.
|
||||
; --------------------------------------------------------------------------
|
||||
align PROC_ALIGN
|
||||
TDock_IsTime4Goodies:
|
||||
mcLoadGameDataPtr esi
|
||||
|
||||
fld [esi + TREKDATA.DATE]
|
||||
fld [esi + TREKDATA.DOCKDATE]
|
||||
fsubp
|
||||
fld [glb_dbl_0dot8]
|
||||
mc_CMP_ST0_ST1
|
||||
|
||||
ret
|
||||
|
||||
; --------------------------------------------------------------------------
|
||||
; Check if enhanced torpedoes available
|
||||
; --------------------------------------------------------------------------
|
||||
align PROC_ALIGN
|
||||
TDock_GetQuantumCharges:
|
||||
call TDock_IsTime4Goodies
|
||||
jnc .done
|
||||
|
||||
mcLoadGameDataPtr esi
|
||||
|
||||
cmp [esi + TREKDATA.QTORPS], 1
|
||||
je .done
|
||||
cmp [esi + TREKDATA.SKILL], 5
|
||||
jb .done
|
||||
|
||||
mcLoad8bitsToReg32 edx, 100
|
||||
call TRandom_IRan
|
||||
inc eax
|
||||
cmp eax, 25
|
||||
ja .done
|
||||
|
||||
mcLoadGameDataPtr edi
|
||||
inc [edi + TREKDATA.QTORPS]
|
||||
|
||||
mcZeroBits ecx
|
||||
cmp [edi + TREKDATA.SHIP], CHAR_ENTERPRISE
|
||||
sete cl
|
||||
mov al, 8
|
||||
shl al, cl
|
||||
mov [edi + TREKDATA.TORPS], al
|
||||
|
||||
.report:
|
||||
call TConsole_SetCrewMsgAttr
|
||||
mov ecx, 707
|
||||
call TConsole_Prout
|
||||
|
||||
.done:
|
||||
ret
|
||||
|
||||
; --------------------------------------------------------------------------
|
||||
; Check if additional photon tubes were installed
|
||||
; --------------------------------------------------------------------------
|
||||
align PROC_ALIGN
|
||||
TDock_InstallTubes:
|
||||
mcBeginLocals 4
|
||||
|
||||
mcLoadGameDataPtr esi
|
||||
cmp [esi + TREKDATA.SKILL], 5
|
||||
jb .done
|
||||
|
||||
cmp [esi + TREKDATA.NPTUBES], 3
|
||||
ja .done
|
||||
|
||||
mcLoad8bitsToReg32 edx, 100
|
||||
call TRandom_IRan
|
||||
inc eax
|
||||
cmp eax, 20
|
||||
ja .done
|
||||
|
||||
call TRandom_Ranf
|
||||
fld [glb_dbl_3]
|
||||
fmulp
|
||||
call TCommon_FP_Truncate
|
||||
inc eax
|
||||
mov [esp], eax
|
||||
|
||||
mcLoadGameDataPtr edi
|
||||
add [edi + TREKDATA.NPTUBES], al
|
||||
|
||||
call TConsole_SetCrewMsgAttr
|
||||
mov ecx, 701
|
||||
call TConsole_Cram
|
||||
|
||||
mov eax, [esp]
|
||||
call TConsole_CramInt
|
||||
|
||||
mov ecx, 702
|
||||
call TConsole_Cram
|
||||
|
||||
cmp dword [esp], 1
|
||||
je .skip
|
||||
|
||||
mov al, 'S'
|
||||
call TConsole_PutChar
|
||||
|
||||
.skip:
|
||||
mov ecx, 703
|
||||
call TConsole_Prout
|
||||
|
||||
.done:
|
||||
mcEndLocals 4
|
||||
ret
|
||||
|
||||
; --------------------------------------------------------------------------
|
||||
; DOCK
|
||||
; --------------------------------------------------------------------------
|
||||
align PROC_ALIGN
|
||||
TDock_Main:
|
||||
call TConsole_SetGameMsgAttr
|
||||
|
||||
mcLoadGameDataPtr esi
|
||||
mov [esi + TREKDATA.IDIDIT], 0
|
||||
|
||||
cmp [esi + TREKDATA.CONDIT], CONDITION_DOCKED
|
||||
je .L30
|
||||
|
||||
cmp [esi + TREKDATA.INORBIT], 0
|
||||
jne .L40
|
||||
|
||||
cmp [esi + TREKDATA.BASEX], 0
|
||||
je .L5
|
||||
|
||||
mov al, [esi + TREKDATA.SECTX]
|
||||
mov dl, [esi + TREKDATA.SECTY]
|
||||
sub al, [esi + TREKDATA.BASEX]
|
||||
sub dl, [esi + TREKDATA.BASEY]
|
||||
movsx eax, al
|
||||
movsx edx, dl
|
||||
|
||||
call TCommon_AbsEAX
|
||||
cmp eax, 1
|
||||
ja .L5
|
||||
|
||||
mov eax, edx
|
||||
call TCommon_AbsEAX
|
||||
cmp eax, 1
|
||||
jbe .L10
|
||||
|
||||
.L5:
|
||||
call TConsole_CramShip
|
||||
mov ecx, 264
|
||||
jmp .msg_end
|
||||
|
||||
.L10:
|
||||
mcLoadGameDataPtr edi
|
||||
mov [edi + TREKDATA.CONDIT], CONDITION_DOCKED
|
||||
|
||||
mov ecx, 265
|
||||
call TConsole_Prout
|
||||
|
||||
call TDock_InstallTubes
|
||||
call TDock_GetQuantumCharges
|
||||
|
||||
mcLoadGameDataPtr edi
|
||||
inc [edi + TREKDATA.IDIDIT]
|
||||
|
||||
fld [edi + TREKDATA.INSHLD]
|
||||
fstp [edi + TREKDATA.SHLD]
|
||||
|
||||
fld [edi + TREKDATA.INLSR]
|
||||
fstp [edi + TREKDATA.LSUPRES]
|
||||
|
||||
cmp [edi + TREKDATA.QTORPS], 1
|
||||
je .check_power
|
||||
|
||||
mov al, [edi + TREKDATA.INTORPS]
|
||||
mov [edi + TREKDATA.TORPS], al
|
||||
|
||||
.check_power:
|
||||
fld [edi + TREKDATA.INENRG]
|
||||
fld [edi + TREKDATA.ENERGY]
|
||||
mc_CMP_ST0_ST1
|
||||
jc .refuel
|
||||
ret
|
||||
|
||||
.refuel:
|
||||
fld [edi + TREKDATA.INENRG]
|
||||
fstp [edi + TREKDATA.ENERGY]
|
||||
ret
|
||||
|
||||
.L30:
|
||||
mov ecx, 266
|
||||
jmp .msg_end
|
||||
|
||||
.L40:
|
||||
mov ecx, 267
|
||||
|
||||
.msg_end:
|
||||
call TConsole_Prout
|
||||
|
||||
mcLoadGameDataPtr esi
|
||||
fld [esi + TREKDATA.DATE]
|
||||
fstp [esi + TREKDATA.DOCKDATE]
|
||||
ret
|
||||
|
||||
; --------------------------------------------------------------------------
|
||||
; HELP
|
||||
; --------------------------------------------------------------------------
|
||||
virtual at 0
|
||||
loc49:
|
||||
.pTrekData PVOID ?
|
||||
.dbl_DIST DOUBLE ?
|
||||
.dbl_XDIST DOUBLE ?
|
||||
.dbl_TEMP1 DOUBLE ?
|
||||
.dbl_TEMP2 DOUBLE ?
|
||||
.dbl_PROBF DOUBLE ?
|
||||
.nIX BYTE ?
|
||||
.nIY BYTE ?
|
||||
.nLINE INDEX ?
|
||||
.nL INDEX ?
|
||||
.nLL INDEX ?
|
||||
.nSUM INT32 ?
|
||||
.size = $
|
||||
end virtual
|
||||
; --------------------------------------------------------------------------
|
||||
align PROC_ALIGN
|
||||
TDock_Help:
|
||||
mcBeginLocals loc49.size
|
||||
|
||||
mcLoadGameDataPtr esi
|
||||
mcStoreLocal loc49.pTrekData, esi
|
||||
|
||||
cmp [esi + TREKDATA.CONDIT], CONDITION_DOCKED
|
||||
jne .L10
|
||||
|
||||
call TConsole_SetCrewMsgAttr
|
||||
mov ecx, 562
|
||||
call TConsole_Prout
|
||||
jmp .done
|
||||
|
||||
.L10:
|
||||
mov cl, DEV_SUBSPACE_RADIO
|
||||
call TArray_IsDamaged
|
||||
jnc .L20
|
||||
|
||||
mov ecx, 563
|
||||
call TConsole_ProutGameMsg
|
||||
jmp .done
|
||||
|
||||
.L20:
|
||||
mcLoadLocal esi, loc49.pTrekData
|
||||
cmp [esi + TREKDATA.REMBASE], 0
|
||||
jne .L30
|
||||
|
||||
call TConsole_SetCrewMsgAttr
|
||||
mov ecx, 564
|
||||
call TConsole_Prout
|
||||
jmp .done
|
||||
|
||||
.L30:
|
||||
cmp [esi + TREKDATA.LANDED], 1
|
||||
jne .L31
|
||||
|
||||
call TConsole_SetGameMsgAttr
|
||||
mov ecx, 565
|
||||
call TConsole_Cram
|
||||
call TConsole_CramShip
|
||||
mov al, '.'
|
||||
call TConsole_PutChar
|
||||
call TConsole_ScrollUp
|
||||
jmp .done
|
||||
|
||||
.L31:
|
||||
cmp [esi + TREKDATA.ISCRAFT], 0
|
||||
jne .L32
|
||||
|
||||
mov ecx, 407
|
||||
call TConsole_ProutGameMsg
|
||||
jmp .done
|
||||
|
||||
.L32:
|
||||
inc [esi + TREKDATA.NHELP]
|
||||
cmp [esi + TREKDATA.BASEX], 0
|
||||
je .L40
|
||||
|
||||
mov al, [esi + TREKDATA.BASEX]
|
||||
sub al, [esi + TREKDATA.SECTX]
|
||||
movzx eax, al
|
||||
imul eax, eax
|
||||
|
||||
mov dl, [esi + TREKDATA.BASEY]
|
||||
sub dl, [esi + TREKDATA.SECTY]
|
||||
movzx edx, dl
|
||||
imul edx, edx
|
||||
|
||||
add eax, edx
|
||||
call TCommon_FPU_Load_EAX
|
||||
fsqrt
|
||||
fstp [esp + loc49.dbl_DIST]
|
||||
jmp .L60
|
||||
|
||||
.L40:
|
||||
fld [glb_dbl_1000]
|
||||
fstp [esp + loc49.dbl_DIST]
|
||||
|
||||
movzx ecx, [esi + TREKDATA.REMBASE]
|
||||
lea edi, [esi + TREKDATA.BASEQX]
|
||||
lea ebx, [esi + TREKDATA.BASEQY]
|
||||
mcZeroBits edx
|
||||
|
||||
.check_base_distance:
|
||||
mov al, [edi]
|
||||
sub al, [esi + TREKDATA.QUADX]
|
||||
movsx eax, al
|
||||
imul eax, eax
|
||||
mcStoreLocal loc49.nSUM, eax
|
||||
|
||||
mov al, [ebx]
|
||||
sub al, [esi + TREKDATA.QUADY]
|
||||
movsx eax, al
|
||||
imul eax, eax
|
||||
add eax, [esp + loc49.nSUM]
|
||||
|
||||
call TCommon_FPU_Load_EAX
|
||||
fsqrt
|
||||
fld [glb_dbl_Ten]
|
||||
fmulp
|
||||
fld st
|
||||
fstp [esp + loc49.dbl_XDIST]
|
||||
|
||||
fld [esp + loc49.dbl_DIST]
|
||||
mc_CMP_ST0_ST1
|
||||
jc .next_base
|
||||
|
||||
fld [esp + loc49.dbl_XDIST]
|
||||
fstp [esp + loc49.dbl_DIST]
|
||||
mcStoreLocal loc49.nLINE, edx
|
||||
|
||||
.next_base:
|
||||
inc edi
|
||||
inc ebx
|
||||
inc edx
|
||||
loop .check_base_distance
|
||||
|
||||
lea edi, [esi + TREKDATA.BASEQX]
|
||||
lea ebx, [esi + TREKDATA.BASEQY]
|
||||
mcLoadLocal ecx, loc49.nLINE
|
||||
|
||||
mov al, [edi + ecx]
|
||||
mov dl, [ebx + ecx]
|
||||
mov [esi + TREKDATA.QUADX], al
|
||||
mov [esi + TREKDATA.QUADY], dl
|
||||
|
||||
inc [esi + TREKDATA.SHUTUP]
|
||||
push esi
|
||||
call TCommon_NewQuad
|
||||
pop esi
|
||||
dec [esi + TREKDATA.SHUTUP]
|
||||
|
||||
.L60:
|
||||
mov al, [esi + TREKDATA.SECTX]
|
||||
mov dl, [esi + TREKDATA.SECTY]
|
||||
call TArray_QuadPtr
|
||||
mov byte [ebx], CHAR_COSMOS
|
||||
|
||||
call TConsole_SetGameMsgAttr
|
||||
mov ecx, 199
|
||||
call TConsole_Cram
|
||||
|
||||
mov cl, 1
|
||||
mcLoadLocal esi, loc49.pTrekData
|
||||
mov al, [esi + TREKDATA.QUADX]
|
||||
mov dl, [esi + TREKDATA.QUADY]
|
||||
call TConsole_CramLoc
|
||||
mov ecx, 566
|
||||
call TConsole_Cram
|
||||
call TConsole_CramShip
|
||||
mov ecx, 567
|
||||
call TConsole_Prout
|
||||
|
||||
mov esi, glb_dbl_0dot98
|
||||
mcLoadLocalRef edi, loc49.dbl_DIST
|
||||
call TCommon_X_exp_Y
|
||||
fld1
|
||||
fsubrp
|
||||
fstp [esp + loc49.dbl_TEMP1]
|
||||
|
||||
fld1
|
||||
fld [glb_dbl_3]
|
||||
fdivp
|
||||
fstp [esp + loc49.dbl_TEMP2]
|
||||
|
||||
mcLoadLocalRef esi, loc49.dbl_TEMP1
|
||||
mcLoadLocalRef edi, loc49.dbl_TEMP2
|
||||
call TCommon_X_exp_Y
|
||||
fstp [esp + loc49.dbl_PROBF]
|
||||
|
||||
mcLoad1 eax
|
||||
mcStoreLocal loc49.nL, eax
|
||||
call TConsole_SetGameMsgAttr
|
||||
|
||||
.attempt:
|
||||
mov ecx, 567
|
||||
add ecx, [esp + loc49.nL]
|
||||
call TConsole_Cram
|
||||
|
||||
mov ecx, 571
|
||||
call TConsole_Cram
|
||||
call TConsole_CramShip
|
||||
mov ecx, 572
|
||||
call TConsole_Cram
|
||||
invoke Sleep, 1200
|
||||
|
||||
call TRandom_Ranf
|
||||
fld [esp + loc49.dbl_PROBF]
|
||||
mc_CMP_ST0_ST1
|
||||
jc .L90
|
||||
|
||||
.L70:
|
||||
mov ecx, 573
|
||||
call TConsole_Prout
|
||||
|
||||
inc [esp + loc49.nL]
|
||||
cmp [esp + loc49.nL], 3
|
||||
jbe .attempt
|
||||
|
||||
mov al, 11
|
||||
call TFinish_Main
|
||||
jmp .done
|
||||
|
||||
.L90:
|
||||
mcLoad1 eax
|
||||
mcStoreLocal loc49.nLL, eax
|
||||
|
||||
mcLoadLocal esi, loc49.pTrekData
|
||||
|
||||
.find_adjacent_pos:
|
||||
call TRandom_Ranf
|
||||
fld [glb_dbl_3]
|
||||
fmulp
|
||||
call TCommon_FP_Truncate
|
||||
add al, [esi + TREKDATA.BASEX]
|
||||
dec eax
|
||||
call TPhotons_IsValidSector
|
||||
jnc .next_adjacent_try
|
||||
mcStoreLocal loc49.nIX, al
|
||||
|
||||
call TRandom_Ranf
|
||||
fld [glb_dbl_3]
|
||||
fmulp
|
||||
call TCommon_FP_Truncate
|
||||
add al, [esi + TREKDATA.BASEY]
|
||||
dec eax
|
||||
call TPhotons_IsValidSector
|
||||
jnc .next_adjacent_try
|
||||
mcStoreLocal loc49.nIY, al
|
||||
|
||||
mcLoadLocal al, loc49.nIX
|
||||
mcLoadLocal dl, loc49.nIY
|
||||
call TArray_QuadPtr
|
||||
cmp byte [ebx], CHAR_COSMOS
|
||||
je .L110
|
||||
|
||||
.next_adjacent_try:
|
||||
inc [esp + loc49.nLL]
|
||||
cmp [esp + loc49.nLL], 5
|
||||
jbe .find_adjacent_pos
|
||||
jmp .L70
|
||||
|
||||
.L110:
|
||||
push ebx
|
||||
mov ecx, 574
|
||||
call TConsole_Prout
|
||||
pop ebx
|
||||
|
||||
mcLoadLocal esi, loc49.pTrekData
|
||||
mcLoadLocal al, loc49.nIX
|
||||
mcLoadLocal dl, loc49.nIY
|
||||
mov [esi + TREKDATA.SECTX], al
|
||||
mov [esi + TREKDATA.SECTY], dl
|
||||
|
||||
mov al, [esi + TREKDATA.SHIP]
|
||||
mov byte [ebx], al
|
||||
|
||||
call TCommon_ResetDist
|
||||
call TCommon_SortKlingons
|
||||
call TDock_Main
|
||||
|
||||
call TConsole_ScrollUp
|
||||
call TConsole_SetCrewMsgAttr
|
||||
mov ecx, 575
|
||||
call TConsole_Prout
|
||||
|
||||
.done:
|
||||
mcEndLocals loc49.size
|
||||
ret
|
||||
|
||||
; --- EOF ---
|
1931
programs/games/StarTrek/trunk/TEvents.Asm
Normal file
1931
programs/games/StarTrek/trunk/TEvents.Asm
Normal file
File diff suppressed because it is too large
Load Diff
551
programs/games/StarTrek/trunk/TFinish.Asm
Normal file
551
programs/games/StarTrek/trunk/TFinish.Asm
Normal file
@ -0,0 +1,551 @@
|
||||
; --------------------------------------------------------------------------
|
||||
; FILE: TFinish.Asm
|
||||
; DATE: October 13, 2008
|
||||
; --------------------------------------------------------------------------
|
||||
|
||||
; --------------------------------------------------------------------------
|
||||
; FINISH
|
||||
; --------------------------------------------------------------------------
|
||||
; Input:
|
||||
; AL = game ending code
|
||||
; --------------------------------------------------------------------------
|
||||
virtual at 0
|
||||
loc47:
|
||||
.pTrekData PVOID ?
|
||||
.bIGotIt BOOL ?
|
||||
.nEndCode INT32 ?
|
||||
.dbl_DateDiff DOUBLE ?
|
||||
.dbl_RateMax DOUBLE ?
|
||||
.dbl_PerDate DOUBLE ?
|
||||
.dbl_Goodies DOUBLE ?
|
||||
.dbl_Baddies DOUBLE ?
|
||||
.dbl_Advantage DOUBLE ?
|
||||
.size = $
|
||||
end virtual
|
||||
; --------------------------------------------------------------------------
|
||||
align PROC_ALIGN
|
||||
TFinish_Main:
|
||||
mcBeginLocals loc47.size
|
||||
|
||||
movzx eax, al
|
||||
mcStoreLocal loc47.nEndCode, eax
|
||||
|
||||
invoke Sleep, 1000
|
||||
|
||||
mcLoadGameDataPtr edi
|
||||
mcStoreLocal loc47.pTrekData, edi
|
||||
inc [edi + TREKDATA.ALLDONE]
|
||||
|
||||
mcZeroBits eax
|
||||
mcStoreLocal loc47.bIGotIt, eax
|
||||
|
||||
call TConsole_ScrollUp
|
||||
call TConsole_ScrollUp
|
||||
call TConsole_ScrollUp
|
||||
mov cl, ATTR_SHIP
|
||||
call TConsole_SetAttr
|
||||
|
||||
mov ecx, 477
|
||||
call TConsole_Cram
|
||||
|
||||
mov cl, 1
|
||||
mcLoadLocal esi, loc47.pTrekData
|
||||
fld [esi + TREKDATA.DATE]
|
||||
call TConsole_CramFloat
|
||||
|
||||
mov ecx, 478
|
||||
call TConsole_Prout
|
||||
call TConsole_ScrollUp
|
||||
|
||||
mcLoadLocal eax, loc47.nEndCode
|
||||
mcOnRegEqu eax, 1, .L100
|
||||
mcOnRegEqu eax, 2, .L200
|
||||
mcOnRegEqu eax, 3, .L300
|
||||
mcOnRegEqu eax, 4, .L400
|
||||
mcOnRegEqu eax, 5, .L500
|
||||
mcOnRegEqu eax, 6, .L600
|
||||
mcOnRegEqu eax, 7, .L700
|
||||
mcOnRegEqu eax, 8, .L800
|
||||
mcOnRegEqu eax, 9, .L900
|
||||
mcOnRegEqu eax, 10, .L1000
|
||||
mcOnRegEqu eax, 11, .L1100
|
||||
mcOnRegEqu eax, 12, .L5000
|
||||
mcOnRegEqu eax, 13, .L1300
|
||||
mcOnRegEqu eax, 14, .L1400
|
||||
mcOnRegEqu eax, 15, .L1500
|
||||
mcOnRegEqu eax, 16, .L1600
|
||||
mcOnRegEqu eax, 17, .L1700
|
||||
mcOnRegEqu eax, 18, .L1800
|
||||
mcOnRegEqu eax, 21, .L2100
|
||||
mcOnRegEqu eax, 22, .L2200
|
||||
|
||||
;int 3
|
||||
jmp .done
|
||||
|
||||
.L100:
|
||||
mcLoadLocal esi, loc47.pTrekData
|
||||
cmp [esi + TREKDATA.NROMREM], 0
|
||||
je .L105
|
||||
|
||||
movzx eax, [esi + TREKDATA.NROMREM]
|
||||
push eax
|
||||
|
||||
mov ecx, 479
|
||||
call TConsole_Cram
|
||||
pop eax
|
||||
call TConsole_CramInt
|
||||
mov ecx, 480
|
||||
call TConsole_Prout
|
||||
call TConsole_ScrollUp
|
||||
|
||||
.L105:
|
||||
mov ecx, 481
|
||||
call TConsole_Prout
|
||||
mov ecx, 482
|
||||
call TConsole_Prout
|
||||
|
||||
mcLoadLocal esi, loc47.pTrekData
|
||||
mov [esi + TREKDATA.GAMEWON], 1
|
||||
|
||||
cmp [esi + TREKDATA.ALIVE], 0
|
||||
je .L130
|
||||
cmp [esi + TREKDATA.BASEKL], 0
|
||||
jne .L130
|
||||
cmp [esi + TREKDATA.SHIP], CHAR_ENTERPRISE
|
||||
jne .L130
|
||||
|
||||
movzx eax, [esi + TREKDATA.STARKL]
|
||||
imul eax, 5
|
||||
|
||||
movzx ecx, [esi + TREKDATA.CASUAL]
|
||||
add eax, ecx
|
||||
|
||||
movzx ecx, [esi + TREKDATA.NPLANKL]
|
||||
imul ecx, 10
|
||||
add eax, ecx
|
||||
|
||||
movzx ecx, [esi + TREKDATA.NHELP]
|
||||
imul ecx, 45
|
||||
add eax, ecx
|
||||
|
||||
cmp eax, 100
|
||||
jae .L130
|
||||
|
||||
fld [glb_dbl_5]
|
||||
fld [esi + TREKDATA.DATE]
|
||||
fld [esi + TREKDATA.INDATE]
|
||||
fsubp
|
||||
fld st
|
||||
fstp [esp + loc47.dbl_DateDiff]
|
||||
mc_CMP_ST0_ST1
|
||||
jc .L110
|
||||
|
||||
mov al, [esi + TREKDATA.SKILL]
|
||||
call TCommon_LoadByteIntoFPU
|
||||
fld [glb_dbl_0dot1]
|
||||
fmulp
|
||||
inc al
|
||||
call TCommon_LoadByteIntoFPU
|
||||
fmulp
|
||||
fld [glb_dbl_0dot1]
|
||||
faddp
|
||||
fstp [esp + loc47.dbl_RateMax]
|
||||
|
||||
mov al, [esi + TREKDATA.KILLK]
|
||||
add al, [esi + TREKDATA.KILLC]
|
||||
add al, [esi + TREKDATA.NSCKILL]
|
||||
fld [esp + loc47.dbl_DateDiff]
|
||||
fdivp
|
||||
fstp [esp + loc47.dbl_PerDate]
|
||||
|
||||
fld [esp + loc47.dbl_RateMax]
|
||||
fld [esp + loc47.dbl_PerDate]
|
||||
mc_CMP_ST0_ST1
|
||||
jc .L130
|
||||
|
||||
.L110:
|
||||
call TConsole_ScrollUp
|
||||
mov ecx, 483
|
||||
call TConsole_Prout
|
||||
|
||||
mcLoadLocal esi, loc47.pTrekData
|
||||
cmp [esi + TREKDATA.SKILL], 4
|
||||
je .L120
|
||||
cmp [esi + TREKDATA.SKILL], 5
|
||||
je .L125
|
||||
|
||||
mov ecx, 484
|
||||
call TConsole_Cram
|
||||
|
||||
mov ecx, 484
|
||||
mcLoadLocal esi, loc47.pTrekData
|
||||
movzx eax, [esi + TREKDATA.SKILL]
|
||||
add ecx, eax
|
||||
call TConsole_Prout
|
||||
|
||||
mov ecx, 488
|
||||
call TConsole_Prout
|
||||
jmp .L130
|
||||
|
||||
.L120:
|
||||
mov ecx, 489
|
||||
call TConsole_Prout
|
||||
inc [esp + loc47.bIGotIt]
|
||||
|
||||
call TConsole_ScrollUp
|
||||
mov ecx, 490
|
||||
call TConsole_Prout
|
||||
mov ecx, 491
|
||||
call TConsole_Prout
|
||||
mov ecx, 492
|
||||
call TConsole_Prout
|
||||
jmp .L130
|
||||
|
||||
.L125:
|
||||
call TConsole_ScrollUp
|
||||
mov ecx, 493
|
||||
call TConsole_Prout
|
||||
|
||||
call TConsole_ScrollUp
|
||||
mov ecx, 494
|
||||
call TConsole_Prout
|
||||
|
||||
mov ecx, 495
|
||||
call TConsole_Prout
|
||||
mov ecx, 495
|
||||
call TConsole_Prout
|
||||
mov ecx, 495
|
||||
call TConsole_Prout
|
||||
mov ecx, 496
|
||||
call TConsole_Prout
|
||||
call TConsole_ScrollUp
|
||||
|
||||
mov ecx, 497
|
||||
call TConsole_Prout
|
||||
|
||||
inc [esp + loc47.bIGotIt]
|
||||
|
||||
.L130:
|
||||
call TConsole_ScrollUp
|
||||
mov ecx, 498
|
||||
call TConsole_Prout
|
||||
call TGame_Score
|
||||
|
||||
cmp [esp + loc47.bIGotIt], 0
|
||||
je .done
|
||||
|
||||
call TApp_PlaqueProcessor
|
||||
jmp .done
|
||||
|
||||
.L200:
|
||||
mov ecx, 499
|
||||
call TConsole_Prout
|
||||
mov ecx, 500
|
||||
call TConsole_Prout
|
||||
call TConsole_ScrollUp
|
||||
|
||||
mov ecx, 501
|
||||
call TConsole_Prout
|
||||
mov ecx, 502
|
||||
call TConsole_Prout
|
||||
|
||||
mcLoadLocal esi, loc47.pTrekData
|
||||
movzx eax, [esi + TREKDATA.REMKL]
|
||||
movzx edx, [esi + TREKDATA.INKLING]
|
||||
imul eax, 3
|
||||
cmp eax, edx
|
||||
ja .L210
|
||||
|
||||
mov ecx, 503
|
||||
call TConsole_Prout
|
||||
|
||||
mcLoadLocal esi, loc47.pTrekData
|
||||
mov [esi + TREKDATA.ALIVE], 0
|
||||
|
||||
.score_and_return:
|
||||
call TGame_Score
|
||||
jmp .done
|
||||
|
||||
.L210:
|
||||
mov ecx, 504
|
||||
call TConsole_Prout
|
||||
call TConsole_ScrollUp
|
||||
mov ecx, 498
|
||||
call TConsole_Prout
|
||||
jmp .score_and_return
|
||||
|
||||
.L300:
|
||||
mov ecx, 505
|
||||
call TConsole_Prout
|
||||
mov ecx, 506
|
||||
call TConsole_Prout
|
||||
|
||||
.L310:
|
||||
call TConsole_ScrollUp
|
||||
mov ecx, 507
|
||||
call TConsole_Prout
|
||||
jmp .L5000
|
||||
|
||||
.L400:
|
||||
mov ecx, 508
|
||||
call TConsole_Prout
|
||||
jmp .L310
|
||||
|
||||
.L500:
|
||||
mov ecx, 509
|
||||
call TConsole_Cram
|
||||
call TConsole_CramShip
|
||||
mov ecx, 510
|
||||
call TConsole_Prout
|
||||
|
||||
call TConsole_ScrollUp
|
||||
mov ecx, 511
|
||||
call TConsole_Prout
|
||||
jmp .L5000
|
||||
|
||||
.L600:
|
||||
mov ecx, 512
|
||||
call TConsole_Prout
|
||||
mov ecx, 513
|
||||
call TConsole_Prout
|
||||
call TConsole_ScrollUp
|
||||
mov ecx, 514
|
||||
call TConsole_Prout
|
||||
jmp .score_and_return
|
||||
|
||||
.L700:
|
||||
mov ecx, 515
|
||||
call TConsole_Prout
|
||||
|
||||
.L705:
|
||||
mov ecx, 516
|
||||
call TConsole_Prout
|
||||
jmp .L5000
|
||||
|
||||
.L800:
|
||||
mov ecx, 509
|
||||
call TConsole_Cram
|
||||
call TConsole_CramShip
|
||||
mov ecx, 517
|
||||
call TConsole_Prout
|
||||
mov ecx, 518
|
||||
call TConsole_Prout
|
||||
jmp .L5000
|
||||
|
||||
.L900:
|
||||
mov ecx, 519
|
||||
call TConsole_Prout
|
||||
mov ecx, 520
|
||||
call TConsole_Prout
|
||||
mov ecx, 521
|
||||
call TConsole_Prout
|
||||
mov ecx, 522
|
||||
call TConsole_Prout
|
||||
jmp .L5000
|
||||
|
||||
.L1000:
|
||||
mov ecx, 523
|
||||
call TConsole_Prout
|
||||
jmp .L5000
|
||||
|
||||
.L1100:
|
||||
mov ecx, 524
|
||||
call TConsole_Prout
|
||||
mov ecx, 525
|
||||
call TConsole_Prout
|
||||
jmp .L5000
|
||||
|
||||
.L1300:
|
||||
mov ecx, 526
|
||||
call TConsole_Prout
|
||||
mov ecx, 527
|
||||
call TConsole_Prout
|
||||
jmp .L1410
|
||||
|
||||
.L1400:
|
||||
mcLoadLocal esi, loc47.pTrekData
|
||||
movzx ecx, [esi + TREKDATA.IPLANET]
|
||||
call TArray_PlanetPtr
|
||||
mov al, [edi + TPlanet.planet_CLASS]
|
||||
mcOnRegNotEqu al, 1, .L1401
|
||||
|
||||
mov ecx, 528
|
||||
call TConsole_Prout
|
||||
mov ecx, 529
|
||||
call TConsole_Prout
|
||||
call TConsole_ScrollUp
|
||||
mov ecx, 530
|
||||
call TConsole_Prout
|
||||
jmp .L1410
|
||||
|
||||
.L1401:
|
||||
push eax
|
||||
mov ecx, 531
|
||||
call TConsole_Prout
|
||||
mov ecx, 532
|
||||
call TConsole_Cram
|
||||
pop eax
|
||||
add al, 'L'
|
||||
call TConsole_PutChar
|
||||
mov ecx, 533
|
||||
call TConsole_Prout
|
||||
mov ecx, 534
|
||||
call TConsole_Prout
|
||||
mov ecx, 535
|
||||
call TConsole_Prout
|
||||
|
||||
.L1410:
|
||||
call TConsole_ScrollUp
|
||||
mov ecx, 536
|
||||
call TConsole_Prout
|
||||
call TConsole_CramShip
|
||||
mov ecx, 537
|
||||
call TConsole_Prout
|
||||
jmp .L5000
|
||||
|
||||
.L1500:
|
||||
mov ecx, 538
|
||||
call TConsole_Prout
|
||||
jmp .L705
|
||||
|
||||
.L1600:
|
||||
mov ecx, 539
|
||||
call TConsole_Prout
|
||||
call TConsole_ScrollUp
|
||||
|
||||
mov ecx, 540
|
||||
call TConsole_Cram
|
||||
call TConsole_CramShip
|
||||
call TConsole_ScrollUp
|
||||
|
||||
mov ecx, 541
|
||||
call TConsole_Prout
|
||||
jmp .L5000
|
||||
|
||||
.L1700:
|
||||
mov ecx, 542
|
||||
call TConsole_Prout
|
||||
jmp .L1600
|
||||
|
||||
.L1800:
|
||||
mov ecx, 543
|
||||
call TConsole_Prout
|
||||
mov ecx, 544
|
||||
call TConsole_Prout
|
||||
call TConsole_ScrollUp
|
||||
mov ecx, 545
|
||||
call TConsole_Prout
|
||||
jmp .L1410
|
||||
|
||||
.L2100:
|
||||
mov ecx, 546
|
||||
call TConsole_Prout
|
||||
mov ecx, 547
|
||||
call TConsole_Prout
|
||||
jmp .L5000
|
||||
|
||||
.L2200:
|
||||
mov ecx, 548
|
||||
call TConsole_Prout
|
||||
mov ecx, 549
|
||||
call TConsole_Prout
|
||||
jmp .L705
|
||||
|
||||
.L5000:
|
||||
call TConsole_ScrollUp
|
||||
mcLoadLocal esi, loc47.pTrekData
|
||||
mov [esi + TREKDATA.ALIVE], 0
|
||||
|
||||
mcZeroBits edx
|
||||
mcZeroBits eax
|
||||
mov al, CHAR_FQUEENE
|
||||
cmp [esi + TREKDATA.SHIP], CHAR_ENTERPRISE
|
||||
cmove edx, eax
|
||||
mov [esi + TREKDATA.SHIP], dl
|
||||
|
||||
cmp [esi + TREKDATA.REMKL], 0
|
||||
je .L5050
|
||||
|
||||
fld [esi + TREKDATA.REMRES]
|
||||
fld [esi + TREKDATA.INRESOR]
|
||||
fdivp
|
||||
fstp [esp + loc47.dbl_Goodies]
|
||||
|
||||
mov al, [esi + TREKDATA.REMCOM]
|
||||
add al, al
|
||||
add al, [esi + TREKDATA.REMKL]
|
||||
call TCommon_LoadByteIntoFPU
|
||||
|
||||
mov al, [esi + TREKDATA.INCOM]
|
||||
add al, al
|
||||
add al, [esi + TREKDATA.INKLING]
|
||||
call TCommon_LoadByteIntoFPU
|
||||
|
||||
fdivp
|
||||
fstp [esp + loc47.dbl_Baddies]
|
||||
|
||||
fld [esp + loc47.dbl_Goodies]
|
||||
fld [esp + loc47.dbl_Baddies]
|
||||
fdivp
|
||||
fstp [esp + loc47.dbl_Advantage]
|
||||
|
||||
call TRandom_Ranf
|
||||
fld [glb_dbl_0dot5]
|
||||
fmulp
|
||||
fld1
|
||||
faddp
|
||||
fld [esp + loc47.dbl_Advantage]
|
||||
mc_CMP_ST0_ST1
|
||||
jc .L5020
|
||||
|
||||
mov ecx, 550
|
||||
call TConsole_Prout
|
||||
mov ecx, 551
|
||||
call TConsole_Prout
|
||||
|
||||
call TRandom_Ranf
|
||||
fld [glb_dbl_3]
|
||||
faddp
|
||||
fld [esp + loc47.dbl_Advantage]
|
||||
mc_CMP_ST0_ST1
|
||||
jc .L5010
|
||||
|
||||
mov ecx, 552
|
||||
call TConsole_Prout
|
||||
call TConsole_ScrollUp
|
||||
mov ecx, 555
|
||||
call TConsole_Prout
|
||||
jmp .L5030
|
||||
|
||||
.L5010:
|
||||
mov ecx, 553
|
||||
call TConsole_Prout
|
||||
jmp .L5030
|
||||
|
||||
.L5020:
|
||||
mov ecx, 554
|
||||
call TConsole_Prout
|
||||
jmp .L5030
|
||||
|
||||
.L5050:
|
||||
mov ecx, 556
|
||||
call TConsole_Prout
|
||||
mov ecx, 557
|
||||
call TConsole_Prout
|
||||
mov ecx, 558
|
||||
call TConsole_Prout
|
||||
mov ecx, 559
|
||||
call TConsole_Prout
|
||||
|
||||
mcLoadLocal ebx, loc47.pTrekData
|
||||
mov [ebx + TREKDATA.GAMEWON], 1
|
||||
mov [ebx + TREKDATA.ALIVE], 0
|
||||
|
||||
.L5030:
|
||||
call TGame_Score
|
||||
|
||||
.done:
|
||||
mcEndLocals loc47.size
|
||||
ret
|
||||
|
||||
; --- EOF ---
|
155
programs/games/StarTrek/trunk/TFormat.Asm
Normal file
155
programs/games/StarTrek/trunk/TFormat.Asm
Normal file
@ -0,0 +1,155 @@
|
||||
; --------------------------------------------------------------------------
|
||||
; FILE: TFormat.Asm
|
||||
; DATE: October 7, 2008
|
||||
; --------------------------------------------------------------------------
|
||||
|
||||
; --------------------------------------------------------------------------
|
||||
; Input:
|
||||
; EDI = ANSI buffer
|
||||
; EAX = value to format
|
||||
; Output:
|
||||
; ECX = length of text
|
||||
; NOTE:
|
||||
; All registers are safe
|
||||
; --------------------------------------------------------------------------
|
||||
virtual at 0
|
||||
loc18:
|
||||
.buffer CHARS 12
|
||||
.nChars INT32 ?
|
||||
.bSigned BOOL ?
|
||||
.size = $
|
||||
end virtual
|
||||
; --------------------------------------------------------------------------
|
||||
align PROC_ALIGN
|
||||
TFormat_Int32:
|
||||
push edx eax esi edi
|
||||
mcBeginLocals loc18.size
|
||||
|
||||
mcLoadLocalRef esi, loc18.nChars
|
||||
mcLoad8bitsToReg32 ecx, 10
|
||||
mcZeroBits edx
|
||||
mcStoreLocal loc18.nChars, edx
|
||||
mcStoreLocal loc18.bSigned, edx
|
||||
|
||||
add eax, edx
|
||||
jns .div_10
|
||||
|
||||
neg eax
|
||||
inc [esp + loc18.bSigned]
|
||||
|
||||
.div_10:
|
||||
mcZeroBits edx
|
||||
div ecx
|
||||
add dl, '0'
|
||||
dec esi
|
||||
mov [esi], dl
|
||||
inc [esp + loc18.nChars]
|
||||
mcOnRegNotZero eax, .div_10
|
||||
|
||||
cmp [esp + loc18.bSigned], 0
|
||||
je .copy
|
||||
|
||||
dec esi
|
||||
mov byte [esi], '-'
|
||||
inc [esp + loc18.nChars]
|
||||
|
||||
.copy:
|
||||
mcLoadLocal ecx, loc18.nChars
|
||||
push ecx
|
||||
rep movsb
|
||||
|
||||
stosb
|
||||
pop ecx
|
||||
|
||||
mcEndLocals loc18.size
|
||||
pop edi esi eax edx
|
||||
ret
|
||||
|
||||
; --------------------------------------------------------------------------
|
||||
; Input:
|
||||
; ST(0) = value to format
|
||||
; EDI = ANSI buffer
|
||||
; CL = number of digits after dot
|
||||
; Output:
|
||||
; ECX = length of text
|
||||
; --------------------------------------------------------------------------
|
||||
virtual at 0
|
||||
loc17:
|
||||
.dbl_Value DOUBLE ?
|
||||
.buf_AllDigits CHARS 10
|
||||
.nValue INT32 ?
|
||||
.nDigits INT32 ?
|
||||
.pszBuffer PCHAR ?
|
||||
.bSigned BOOL ?
|
||||
.size = $
|
||||
end virtual
|
||||
; --------------------------------------------------------------------------
|
||||
align PROC_ALIGN
|
||||
TFormat_Double:
|
||||
push eax ebx esi edi
|
||||
mcBeginLocals loc17.size
|
||||
|
||||
.prepare:
|
||||
mcStoreLocal loc17.pszBuffer, edi
|
||||
movzx ecx, cl
|
||||
mcStoreLocal loc17.nDigits, ecx
|
||||
|
||||
fld1
|
||||
|
||||
.make_factor:
|
||||
fld [glb_dbl_Ten]
|
||||
fmulp
|
||||
loop .make_factor
|
||||
|
||||
fmulp
|
||||
frndint
|
||||
|
||||
call TCommon_FP_Truncate
|
||||
mcStoreLocal loc17.nValue, eax
|
||||
|
||||
mcLoadLocalRef edi, loc17.buf_AllDigits
|
||||
call TFormat_Int32
|
||||
|
||||
cmp ecx, [esp + loc17.nDigits]
|
||||
ja .print_all
|
||||
|
||||
mcLoadLocal ebx, loc17.pszBuffer
|
||||
mov byte [ebx], '0'
|
||||
mov byte [ebx + 1], '.'
|
||||
je .copy_all_at_EBX
|
||||
|
||||
mov al, [edi]
|
||||
mov byte [ebx + 2], '0'
|
||||
mov byte [ebx + 3], al
|
||||
mov byte [ebx + 4], 0
|
||||
jmp .done
|
||||
|
||||
.copy_all_at_EBX:
|
||||
mov esi, edi
|
||||
lea edi, [ebx + 2]
|
||||
inc ecx
|
||||
rep movsb
|
||||
jmp .done
|
||||
|
||||
.print_all:
|
||||
mov esi, edi
|
||||
mcLoadLocal edi, loc17.pszBuffer
|
||||
sub ecx, [esp + loc17.nDigits]
|
||||
rep movsb
|
||||
|
||||
mov al, '.'
|
||||
stosb
|
||||
|
||||
mov ecx, [esp + loc17.nDigits]
|
||||
inc ecx
|
||||
rep movsb
|
||||
|
||||
.done:
|
||||
mcLoadLocal esi, loc17.pszBuffer
|
||||
call TCmdBuf_AnsiStrLen
|
||||
|
||||
mcEndLocals loc17.size
|
||||
pop edi esi ebx eax
|
||||
ret
|
||||
|
||||
; --- EOF ---
|
2420
programs/games/StarTrek/trunk/TGame.Asm
Normal file
2420
programs/games/StarTrek/trunk/TGame.Asm
Normal file
File diff suppressed because it is too large
Load Diff
158
programs/games/StarTrek/trunk/TImpulse.Asm
Normal file
158
programs/games/StarTrek/trunk/TImpulse.Asm
Normal file
@ -0,0 +1,158 @@
|
||||
; --------------------------------------------------------------------------
|
||||
; FILE: TImpulse.Asm
|
||||
; DATE: November 9, 2008
|
||||
; --------------------------------------------------------------------------
|
||||
|
||||
; --------------------------------------------------------------------------
|
||||
; IMPULSE
|
||||
; --------------------------------------------------------------------------
|
||||
virtual at 0
|
||||
loc50:
|
||||
.pTrekData PVOID ?
|
||||
.dbl_POWER DOUBLE ?
|
||||
.__padded__ BYTES 2
|
||||
.size = $
|
||||
end virtual
|
||||
; --------------------------------------------------------------------------
|
||||
align PROC_ALIGN
|
||||
TImpulse_Main:
|
||||
mcBeginLocals loc50.size
|
||||
|
||||
mcLoadGameDataPtr esi
|
||||
mcStoreLocal loc50.pTrekData, esi
|
||||
|
||||
mov [esi + TREKDATA.IDIDIT], 0
|
||||
|
||||
mov cl, DEV_IMPULSE_ENGINES
|
||||
call TArray_IsDamaged
|
||||
jc .L40
|
||||
|
||||
fld [glb_dbl_30]
|
||||
fld [esi + TREKDATA.ENERGY]
|
||||
mc_CMP_ST0_ST1
|
||||
jc .L5
|
||||
jz .L5
|
||||
|
||||
call TMove_GetCourseDistance
|
||||
|
||||
mcLoadLocal esi, loc50.pTrekData
|
||||
fldz
|
||||
fld [esi + TREKDATA.DIREC]
|
||||
mc_CMP_ST0_ST1
|
||||
jc .done
|
||||
|
||||
fld [esi + TREKDATA.DIST]
|
||||
fld [glb_dbl_100]
|
||||
fmulp
|
||||
fld [glb_dbl_20]
|
||||
faddp
|
||||
fstp [esp + loc50.dbl_POWER]
|
||||
|
||||
fld [esi + TREKDATA.ENERGY]
|
||||
fld [esp + loc50.dbl_POWER]
|
||||
mc_CMP_ST0_ST1
|
||||
jc .L20
|
||||
|
||||
.L5:
|
||||
call TConsole_ScrollUp
|
||||
call TConsole_SetCrewMsgAttr
|
||||
mov ecx, 576
|
||||
call TConsole_Prout
|
||||
mov ecx, 577
|
||||
call TConsole_Prout
|
||||
|
||||
mcLoadLocal esi, loc50.pTrekData
|
||||
fld [glb_dbl_30]
|
||||
fld [esi + TREKDATA.ENERGY]
|
||||
mc_CMP_ST0_ST1
|
||||
jnc .L10
|
||||
|
||||
mov ecx, 578
|
||||
call TConsole_Prout
|
||||
jmp .done
|
||||
|
||||
.L10:
|
||||
mov ecx, 579
|
||||
call TConsole_Prout
|
||||
|
||||
mcLoadLocal esi, loc50.pTrekData
|
||||
fld [esi + TREKDATA.ENERGY]
|
||||
fld [glb_dbl_20]
|
||||
fsubp
|
||||
fld [glb_dbl_0dot01]
|
||||
fmulp
|
||||
fld [glb_dbl_0dot05]
|
||||
fsubp
|
||||
|
||||
mov cl, 1
|
||||
call TConsole_CramFloat
|
||||
|
||||
mov ecx, 580
|
||||
call TConsole_Prout
|
||||
jmp .done
|
||||
|
||||
.L20:
|
||||
mcLoadLocal esi, loc50.pTrekData
|
||||
fld [esi + TREKDATA.DIST]
|
||||
fld [glb_dbl_0dot095]
|
||||
fdivp
|
||||
fstp [esi + TREKDATA.TIME]
|
||||
|
||||
fld [esi + TREKDATA.REMTIME]
|
||||
fld [esi + TREKDATA.TIME]
|
||||
mc_CMP_ST0_ST1
|
||||
jc .L30
|
||||
|
||||
call TConsole_SetCrewMsgAttr
|
||||
mov ecx, 581
|
||||
call TConsole_Prout
|
||||
mov ecx, 582
|
||||
call TConsole_Prout
|
||||
mov ecx, 583
|
||||
call TConsole_Prout
|
||||
|
||||
mcLoad8bitsToReg32 ecx, 158
|
||||
call TGame_JA
|
||||
jnc .done
|
||||
|
||||
.L30:
|
||||
call TMove_Move
|
||||
mcLoadLocal esi, loc50.pTrekData
|
||||
inc [esi + TREKDATA.IDIDIT]
|
||||
|
||||
cmp [esi + TREKDATA.ALLDONE], 0
|
||||
jne .done
|
||||
|
||||
fld [esi + TREKDATA.DIST]
|
||||
fld [glb_dbl_100]
|
||||
fmulp
|
||||
fld [glb_dbl_20]
|
||||
faddp
|
||||
fld [esi + TREKDATA.ENERGY]
|
||||
fsubrp
|
||||
fstp [esi + TREKDATA.ENERGY]
|
||||
|
||||
fld [esi + TREKDATA.DIST]
|
||||
fld [glb_dbl_0dot095]
|
||||
fdivp
|
||||
fstp [esi + TREKDATA.TIME]
|
||||
|
||||
fld [esi + TREKDATA.ENERGY]
|
||||
fldz
|
||||
mc_CMP_ST0_ST1
|
||||
jc .done
|
||||
|
||||
mov al, 4
|
||||
call TFinish_Main
|
||||
jmp .done
|
||||
|
||||
.L40:
|
||||
call TConsole_ScrollUp
|
||||
mov ecx, 584
|
||||
call TConsole_ProutGameMsg
|
||||
|
||||
.done:
|
||||
mcEndLocals loc50.size
|
||||
ret
|
||||
|
||||
; --- EOF ---
|
143
programs/games/StarTrek/trunk/TLog.Asm
Normal file
143
programs/games/StarTrek/trunk/TLog.Asm
Normal file
@ -0,0 +1,143 @@
|
||||
; --------------------------------------------------------------------------
|
||||
; FILE: TLog.Asm
|
||||
; DATE: February 21, 2009
|
||||
; --------------------------------------------------------------------------
|
||||
|
||||
; --------------------------------------------------------------------------
|
||||
align PROC_ALIGN
|
||||
TLog_Create:
|
||||
invoke HeapAlloc, [glb_Allocator], HEAP_NO_SERIALIZE, TLog.size
|
||||
mov [glb_pLog], eax
|
||||
|
||||
mov edi, eax
|
||||
mcZeroBits eax
|
||||
|
||||
mov [edi + TLog.nRemainChars], eax
|
||||
mov [edi + TLog.nStoredChars], eax
|
||||
mov [edi + TLog.pCurrentBufPos], eax
|
||||
|
||||
invoke VirtualAlloc, 0, MAX_LOG_ROOM, MEM_COMMIT or MEM_RESERVE, PAGE_READWRITE
|
||||
mov [edi + TLog.pBuffer], eax
|
||||
ret
|
||||
|
||||
; --------------------------------------------------------------------------
|
||||
align PROC_ALIGN
|
||||
TLog_Enable:
|
||||
invoke CreateFile, str_LogFileName, GENERIC_WRITE, \
|
||||
0, 0, CREATE_ALWAYS, FILE_FLAG_SEQ_SCAN, 0
|
||||
|
||||
invoke CloseHandle, eax
|
||||
|
||||
mov edi, [glb_pLog]
|
||||
mcZeroBits eax
|
||||
mov edx, MAX_LOG_ROOM
|
||||
mov ebx, [edi + TLog.pBuffer]
|
||||
|
||||
mov [edi + TLog.nRemainChars], edx
|
||||
mov [edi + TLog.nStoredChars], eax
|
||||
mov [edi + TLog.pCurrentBufPos], ebx
|
||||
ret
|
||||
|
||||
; --------------------------------------------------------------------------
|
||||
align PROC_ALIGN
|
||||
TLog_Backspace:
|
||||
cmp [glb_LogEnabled], 1
|
||||
je .do_it
|
||||
ret
|
||||
|
||||
.do_it:
|
||||
mov esi, [glb_pLog]
|
||||
cmp [esi + TLog.nStoredChars], 0
|
||||
je .print_backspace
|
||||
|
||||
dec [esi + TLog.nStoredChars]
|
||||
dec [esi + TLog.pCurrentBufPos]
|
||||
inc [esi + TLog.nRemainChars]
|
||||
ret
|
||||
|
||||
.print_backspace:
|
||||
mov al, '\'
|
||||
call TLog_DumpChar
|
||||
mov al, 'B'
|
||||
call TLog_DumpChar
|
||||
mov al, 'S'
|
||||
call TLog_DumpChar
|
||||
mov al, 'P'
|
||||
call TLog_DumpChar
|
||||
mov al, '\'
|
||||
call TLog_DumpChar
|
||||
ret
|
||||
|
||||
; --------------------------------------------------------------------------
|
||||
align PROC_ALIGN
|
||||
TLog_Disable:
|
||||
cmp [glb_LogEnabled], 1
|
||||
je .do_it
|
||||
ret
|
||||
|
||||
.do_it:
|
||||
call TLog_Flush
|
||||
ret
|
||||
|
||||
; --------------------------------------------------------------------------
|
||||
align PROC_ALIGN
|
||||
TLog_Flush:
|
||||
mov esi, [glb_pLog]
|
||||
mov ecx, [esi + TLog.nStoredChars]
|
||||
jecxz .done
|
||||
|
||||
invoke CreateFile, str_LogFileName, GENERIC_WRITE, \
|
||||
0, 0, OPEN_EXISTING, FILE_FLAG_SEQ_SCAN, 0
|
||||
|
||||
mov ebx, eax
|
||||
invoke SetFilePointer, eax, 0, 0, 2
|
||||
|
||||
invoke WriteFile, ebx, [esi + TLog.pBuffer], [esi + TLog.nStoredChars], glb_FPU_Int32, 0
|
||||
invoke CloseHandle, ebx
|
||||
|
||||
mcZeroBits eax
|
||||
mov edx, MAX_LOG_ROOM
|
||||
mov ebx, [esi + TLog.pBuffer]
|
||||
|
||||
mov [esi + TLog.nRemainChars], edx
|
||||
mov [esi + TLog.nStoredChars], eax
|
||||
mov [esi + TLog.pCurrentBufPos], ebx
|
||||
|
||||
.done:
|
||||
ret
|
||||
|
||||
; --------------------------------------------------------------------------
|
||||
; Input:
|
||||
; AL = character to append into log buffer.
|
||||
; --------------------------------------------------------------------------
|
||||
align PROC_ALIGN
|
||||
TLog_DumpChar:
|
||||
cmp [glb_LogEnabled], 1
|
||||
je .do_it
|
||||
ret
|
||||
|
||||
.do_it:
|
||||
mcOnRegZero al, .do_backspace
|
||||
|
||||
mov esi, [glb_pLog]
|
||||
cmp [esi + TLog.nRemainChars], 0
|
||||
jne .dump
|
||||
|
||||
push eax
|
||||
call TLog_Flush
|
||||
pop eax
|
||||
mov esi, [glb_pLog]
|
||||
|
||||
.dump:
|
||||
mov edi, [esi + TLog.pCurrentBufPos]
|
||||
stosb
|
||||
mov [esi + TLog.pCurrentBufPos], edi
|
||||
inc [esi + TLog.nStoredChars]
|
||||
dec [esi + TLog.nRemainChars]
|
||||
ret
|
||||
|
||||
.do_backspace:
|
||||
call TLog_Backspace
|
||||
ret
|
||||
|
||||
; --- EOF ---
|
28
programs/games/StarTrek/trunk/TLog.Inc
Normal file
28
programs/games/StarTrek/trunk/TLog.Inc
Normal file
@ -0,0 +1,28 @@
|
||||
; --------------------------------------------------------------------------
|
||||
; FILE: TLog.Inc
|
||||
; DATE: February 21, 2009
|
||||
; --------------------------------------------------------------------------
|
||||
|
||||
MAX_LOG_ROOM = 40000h
|
||||
|
||||
; --------------------------------------------------------------------------
|
||||
PLAQUE_INSERT_KLRATE = 0F8h
|
||||
PLAQUE_INSERT_SCORE = 0F9h
|
||||
PLAQUE_INSERT_DATE = 0FAh
|
||||
PLAQUE_INSERT_LEVEL = 0FBh
|
||||
PLAQUE_INSERT_NAME = 0FCh
|
||||
PLAQUE_STRING = 0FDh
|
||||
PLAQUE_END_OF_LINE = 0FEh
|
||||
PLAQUE_END_OF_ALL = 0FFh
|
||||
|
||||
; --------------------------------------------------------------------------
|
||||
virtual at 0
|
||||
TLog:
|
||||
.pBuffer PCHAR ?
|
||||
.pCurrentBufPos PCHAR ?
|
||||
.nStoredChars COUNT ?
|
||||
.nRemainChars COUNT ?
|
||||
.size = $
|
||||
end virtual
|
||||
|
||||
; --- EOF ---
|
184
programs/games/StarTrek/trunk/TLrScan.Asm
Normal file
184
programs/games/StarTrek/trunk/TLrScan.Asm
Normal file
@ -0,0 +1,184 @@
|
||||
; --------------------------------------------------------------------------
|
||||
; FILE: TLrScan.Asm
|
||||
; DATE: October 11, 2008
|
||||
; --------------------------------------------------------------------------
|
||||
|
||||
; --------------------------------------------------------------------------
|
||||
; Enable/Disable log file
|
||||
; --------------------------------------------------------------------------
|
||||
align PROC_ALIGN
|
||||
TLrScan_Log:
|
||||
call TCmdBuf_Scan
|
||||
|
||||
cmp [ebx + TCmdBuf.cmdbuf_KEY], CMD_TOKEN_ALPHA
|
||||
je .check_yes_no
|
||||
|
||||
cmp [ebx + TCmdBuf.cmdbuf_KEY], CMD_TOKEN_EOL
|
||||
je .print_log_state
|
||||
|
||||
.print_log_format:
|
||||
mov ecx, 712
|
||||
|
||||
.print:
|
||||
call TConsole_ProutGameMsg
|
||||
ret
|
||||
|
||||
.check_yes_no:
|
||||
mcLoad8bitsToReg32 ecx, 159
|
||||
call TCmdBuf_Crop
|
||||
jc .yes
|
||||
|
||||
mcLoad8bitsToReg32 ecx, 122
|
||||
call TCmdBuf_Crop
|
||||
jnc .print_log_format
|
||||
;
|
||||
; Switch logging OFF
|
||||
;
|
||||
cmp [glb_LogEnabled], 0
|
||||
je .msg710
|
||||
|
||||
call TLog_Disable
|
||||
mov [glb_LogEnabled], 0
|
||||
|
||||
.msg710:
|
||||
mov ecx, 710
|
||||
jmp .print
|
||||
|
||||
.yes:
|
||||
;
|
||||
; Switch logging ON
|
||||
;
|
||||
cmp [glb_LogEnabled], 1
|
||||
je .msg711
|
||||
|
||||
mov [glb_LogEnabled], 1
|
||||
call TLog_Enable
|
||||
|
||||
.msg711:
|
||||
mov ecx, 711
|
||||
jmp .print
|
||||
|
||||
.print_log_state:
|
||||
movzx ecx, [glb_LogEnabled]
|
||||
add ecx, 710
|
||||
jmp .print
|
||||
|
||||
; --------------------------------------------------------------------------
|
||||
; Input:
|
||||
; EAX = X quadrant coordinate (may be out of range)
|
||||
; EDX = Y quadrant coordinate (may be out of range)
|
||||
; --------------------------------------------------------------------------
|
||||
align PROC_ALIGN
|
||||
TLrScan_DumpContents:
|
||||
push eax edx
|
||||
|
||||
cmp eax, 1
|
||||
jb .out_of_range
|
||||
cmp edx, 1
|
||||
jb .out_of_range
|
||||
cmp eax, 8
|
||||
ja .out_of_range
|
||||
cmp edx, 8
|
||||
ja .out_of_range
|
||||
|
||||
mcLoad1 ecx
|
||||
call TArray_SetStarChartValue
|
||||
|
||||
mov cl, ATTR_REPORT_VALUE
|
||||
call TConsole_SetAttr
|
||||
|
||||
call TArray_GetGalaxyValue
|
||||
mov eax, ecx
|
||||
mov cl, 5
|
||||
call TConsole_CramIntWidth
|
||||
jmp .done
|
||||
|
||||
.out_of_range:
|
||||
mov cl, ATTR_GALAXY_EDGE
|
||||
call TConsole_SetAttr
|
||||
mcLoad8bitsToReg32 ecx, 134
|
||||
call TConsole_Cram
|
||||
|
||||
.done:
|
||||
pop edx eax
|
||||
ret
|
||||
|
||||
; --------------------------------------------------------------------------
|
||||
; LRSCAN
|
||||
; --------------------------------------------------------------------------
|
||||
align PROC_ALIGN
|
||||
TLrScan_Main:
|
||||
mov cl, DEV_LR_SENSORS
|
||||
call TArray_IsDamaged
|
||||
jnc .proceed
|
||||
|
||||
mcLoadGameDataPtr esi
|
||||
cmp [esi + TREKDATA.CONDIT], CONDITION_DOCKED
|
||||
jne .not_available
|
||||
|
||||
.proceed:
|
||||
call TConsole_ScrollUp
|
||||
mov cl, ATTR_REPORT_TEXT
|
||||
call TConsole_SetAttr
|
||||
mcLoad8bitsToReg32 ecx, 135
|
||||
call TConsole_Cram
|
||||
mov cl, 1
|
||||
mcLoadGameDataPtr ebx
|
||||
mov al, [ebx + TREKDATA.QUADX]
|
||||
mov dl, [ebx + TREKDATA.QUADY]
|
||||
call TConsole_CramLoc
|
||||
call TConsole_ScrollUp
|
||||
call TConsole_ScrollUp
|
||||
;
|
||||
; EAX = QUADX-1
|
||||
; EDX = QUADY-1
|
||||
;
|
||||
mcLoadGameDataPtr ebx
|
||||
movzx eax, [ebx + TREKDATA.QUADX]
|
||||
movzx edx, [ebx + TREKDATA.QUADY]
|
||||
dec eax
|
||||
dec edx
|
||||
|
||||
call TLrScan_DumpContents
|
||||
inc edx
|
||||
call TLrScan_DumpContents
|
||||
inc edx
|
||||
call TLrScan_DumpContents
|
||||
|
||||
push edx eax
|
||||
call TConsole_ScrollUp
|
||||
pop eax edx
|
||||
|
||||
inc eax
|
||||
sub edx, 2
|
||||
call TLrScan_DumpContents
|
||||
inc edx
|
||||
call TLrScan_DumpContents
|
||||
inc edx
|
||||
call TLrScan_DumpContents
|
||||
|
||||
push edx eax
|
||||
call TConsole_ScrollUp
|
||||
pop eax edx
|
||||
|
||||
inc eax
|
||||
sub edx, 2
|
||||
call TLrScan_DumpContents
|
||||
inc edx
|
||||
call TLrScan_DumpContents
|
||||
inc edx
|
||||
call TLrScan_DumpContents
|
||||
call TConsole_ScrollUp
|
||||
jmp .done
|
||||
|
||||
.not_available:
|
||||
call TConsole_ScrollUp
|
||||
call TConsole_SetGameMsgAttr
|
||||
mcLoad8bitsToReg32 ecx, 133
|
||||
call TConsole_Prout
|
||||
|
||||
.done:
|
||||
call TConsole_ScrollUp
|
||||
ret
|
||||
|
||||
; --- EOF ---
|
1786
programs/games/StarTrek/trunk/TMove.Asm
Normal file
1786
programs/games/StarTrek/trunk/TMove.Asm
Normal file
File diff suppressed because it is too large
Load Diff
191
programs/games/StarTrek/trunk/TMsgTable.Asm
Normal file
191
programs/games/StarTrek/trunk/TMsgTable.Asm
Normal file
@ -0,0 +1,191 @@
|
||||
; --------------------------------------------------------------------------
|
||||
; FILE: TMsgTable.Asm
|
||||
; DATE: September 28, 2008
|
||||
; --------------------------------------------------------------------------
|
||||
|
||||
; --------------------------------------------------------------------------
|
||||
align PROC_ALIGN
|
||||
TMsgTable_CountItems:
|
||||
mov esi, [glb_pRawMsgBuffer]
|
||||
mcZeroBits eax
|
||||
mcZeroBits ecx
|
||||
mcZeroBits edx
|
||||
|
||||
.load_char:
|
||||
lodsb
|
||||
mcOnRegZero eax, .done
|
||||
|
||||
cmp al, 0Dh
|
||||
sete dl
|
||||
add ecx, edx
|
||||
jmp .load_char
|
||||
|
||||
.done:
|
||||
mov [glb_NumMsgItems], ecx
|
||||
ret
|
||||
|
||||
; --------------------------------------------------------------------------
|
||||
align PROC_ALIGN
|
||||
TMsgTable_Parse:
|
||||
mov ecx, [glb_NumMsgItems]
|
||||
shl ecx, 2
|
||||
invoke HeapAlloc, [glb_Allocator], HEAP_NO_SERIALIZE, ecx
|
||||
mov [glb_pMsgItems], eax
|
||||
|
||||
mov edi, eax
|
||||
mov esi, [glb_pRawMsgBuffer]
|
||||
mcZeroBits eax
|
||||
mov [glb_NumMsgItems], eax
|
||||
|
||||
.load_char:
|
||||
lodsb
|
||||
mcOnRegZero eax, .done
|
||||
|
||||
mcOnRegEqu al, '{', .begin_item
|
||||
mcOnRegEqu al, '}', .end_item
|
||||
jmp .load_char
|
||||
|
||||
.begin_item:
|
||||
mov [edi], esi
|
||||
add edi, 4
|
||||
inc [glb_NumMsgItems]
|
||||
jmp .load_char
|
||||
|
||||
.end_item:
|
||||
lea edx, [esi - 1]
|
||||
mov byte [edx], 0
|
||||
jmp .load_char
|
||||
|
||||
.done:
|
||||
ret
|
||||
|
||||
; --------------------------------------------------------------------------
|
||||
; Input:
|
||||
; EDI = buffer address
|
||||
; ECX = buffer size in bytes
|
||||
; --------------------------------------------------------------------------
|
||||
align PROC_ALIGN
|
||||
TMsgTable_Decrypt:
|
||||
pushad
|
||||
|
||||
.reset_key:
|
||||
mov esi, TMsgTable_GetItem
|
||||
mcLoad8bitsToReg32 edx, 27
|
||||
|
||||
.next:
|
||||
lodsb
|
||||
xor [edi], al
|
||||
inc edi
|
||||
|
||||
dec ecx
|
||||
jz .done
|
||||
|
||||
dec edx
|
||||
jz .reset_key
|
||||
jmp .next
|
||||
|
||||
.done:
|
||||
popad
|
||||
ret
|
||||
|
||||
; --------------------------------------------------------------------------
|
||||
virtual at 0
|
||||
loc4:
|
||||
.hFile HFILE ?
|
||||
.dwSize UINT32 ?
|
||||
.dwLoaded UINT32 ?
|
||||
.size = $
|
||||
end virtual
|
||||
; --------------------------------------------------------------------------
|
||||
align PROC_ALIGN
|
||||
TMsgTable_Load:
|
||||
mcBeginLocals loc4.size
|
||||
|
||||
invoke CreateFile, str_MsgFileName, GENERIC_READ, \
|
||||
0, 0, OPEN_EXISTING, FILE_FLAG_SEQ_SCAN, 0
|
||||
|
||||
mcStoreLocal loc4.hFile, eax
|
||||
cmp eax, -1
|
||||
je .done
|
||||
|
||||
mov ebx, esp
|
||||
invoke GetFileSize, [ebx + loc4.hFile], 0
|
||||
mcStoreLocal loc4.dwSize, eax
|
||||
mcOnRegZero eax, .close
|
||||
|
||||
inc eax
|
||||
invoke HeapAlloc, [glb_Allocator], HEAP_NO_SERIALIZE, eax
|
||||
mov [glb_pRawMsgBuffer], eax
|
||||
mcOnRegZero eax, .close
|
||||
|
||||
mcLoadMemberRef edi, loc4.dwLoaded
|
||||
|
||||
invoke ReadFile, [ebx + loc4.hFile], eax, \
|
||||
[ebx + loc4.dwSize], edi, 0
|
||||
|
||||
mov edi, [glb_pRawMsgBuffer]
|
||||
mcLoadLocal ecx, loc4.dwLoaded
|
||||
mcZeroBits eax
|
||||
mov [edi + ecx], al
|
||||
|
||||
call TMsgTable_Decrypt
|
||||
call TMsgTable_CountItems
|
||||
call TMsgTable_Parse
|
||||
|
||||
.close:
|
||||
mov ebx, esp
|
||||
invoke CloseHandle, [ebx + loc4.hFile]
|
||||
|
||||
.done:
|
||||
mcEndLocals loc4.size
|
||||
ret
|
||||
|
||||
; --------------------------------------------------------------------------
|
||||
; Input:
|
||||
; ECX = item index (1-based)
|
||||
; Output:
|
||||
; ESI = points to ANSI text at specified index or empty string
|
||||
; --------------------------------------------------------------------------
|
||||
align PROC_ALIGN
|
||||
TMsgTable_GetItem:
|
||||
cmp ecx, [glb_NumMsgItems]
|
||||
ja .empty
|
||||
|
||||
dec ecx
|
||||
push edx
|
||||
mov edx, [glb_pMsgItems]
|
||||
mov esi, [edx + ecx*4]
|
||||
pop edx
|
||||
ret
|
||||
|
||||
.empty:
|
||||
mov esi, str_CharSizeText + 4
|
||||
ret
|
||||
|
||||
; --------------------------------------------------------------------------
|
||||
; Input:
|
||||
; ECX = item index (1-based)
|
||||
; Output:
|
||||
; EAX = string length
|
||||
; --------------------------------------------------------------------------
|
||||
align PROC_ALIGN
|
||||
TMsgTable_GetLength:
|
||||
push esi ecx
|
||||
call TMsgTable_GetItem
|
||||
|
||||
mcZeroBits eax
|
||||
mcZeroBits ecx
|
||||
|
||||
.next_char:
|
||||
lodsb
|
||||
mcOnRegZero eax, .done
|
||||
|
||||
inc ecx
|
||||
jmp .next_char
|
||||
|
||||
.done:
|
||||
mov eax, ecx
|
||||
pop ecx esi
|
||||
ret
|
||||
|
||||
; --- EOF ---
|
1410
programs/games/StarTrek/trunk/TNova.Asm
Normal file
1410
programs/games/StarTrek/trunk/TNova.Asm
Normal file
File diff suppressed because it is too large
Load Diff
1424
programs/games/StarTrek/trunk/TPhasers.Asm
Normal file
1424
programs/games/StarTrek/trunk/TPhasers.Asm
Normal file
File diff suppressed because it is too large
Load Diff
1571
programs/games/StarTrek/trunk/TPhotons.Asm
Normal file
1571
programs/games/StarTrek/trunk/TPhotons.Asm
Normal file
File diff suppressed because it is too large
Load Diff
1069
programs/games/StarTrek/trunk/TPlanet.Asm
Normal file
1069
programs/games/StarTrek/trunk/TPlanet.Asm
Normal file
File diff suppressed because it is too large
Load Diff
324
programs/games/StarTrek/trunk/TRandom.Asm
Normal file
324
programs/games/StarTrek/trunk/TRandom.Asm
Normal file
@ -0,0 +1,324 @@
|
||||
; --------------------------------------------------------------------------
|
||||
; FILE: TRandom.Asm
|
||||
; DATE: October 4, 2008
|
||||
; --------------------------------------------------------------------------
|
||||
|
||||
; --------------------------------------------------------------------------
|
||||
align PROC_ALIGN
|
||||
TRandom_Create:
|
||||
invoke HeapAlloc, [glb_Allocator], HEAP_NO_SERIALIZE, TRandom.size
|
||||
mov [glb_pMersenne], eax
|
||||
|
||||
mcZeroBits ecx
|
||||
mov [eax + TRandom.rand_NextIndex], ecx
|
||||
|
||||
rdtsc
|
||||
call TRandom_Seed
|
||||
ret
|
||||
|
||||
; --------------------------------------------------------------------------
|
||||
; Input:
|
||||
; EAX = seed value
|
||||
; --------------------------------------------------------------------------
|
||||
virtual at 0
|
||||
loc7:
|
||||
.index INDEX ?
|
||||
.size = $
|
||||
end virtual
|
||||
; --------------------------------------------------------------------------
|
||||
align PROC_ALIGN
|
||||
TRandom_Seed:
|
||||
mcBeginLocals loc7.size
|
||||
|
||||
mcLoad1 ecx
|
||||
mcStoreLocal loc7.index, ecx
|
||||
|
||||
mov edi, [glb_pMersenne]
|
||||
stosd
|
||||
|
||||
.set_next_value:
|
||||
;
|
||||
; MT [i-1]
|
||||
;
|
||||
mov edx, [edi - 4]
|
||||
;
|
||||
; Right shift by 30 bits
|
||||
;
|
||||
mov eax, edx
|
||||
shr eax, 30
|
||||
;
|
||||
; XOR it with MT [i-1]
|
||||
;
|
||||
xor edx, eax
|
||||
;
|
||||
; Add current index
|
||||
;
|
||||
add edx, [esp + loc7.index]
|
||||
;
|
||||
; Multiply by 6C078965h
|
||||
;
|
||||
mov eax, 6C078965h
|
||||
mul edx
|
||||
;
|
||||
; Store as MT [i]
|
||||
;
|
||||
stosd
|
||||
;
|
||||
; Continue until index reaches 623
|
||||
;
|
||||
inc [esp + loc7.index]
|
||||
cmp [esp + loc7.index], 623
|
||||
jbe .set_next_value
|
||||
|
||||
mcEndLocals loc7.size
|
||||
ret
|
||||
|
||||
; --------------------------------------------------------------------------
|
||||
; Input:
|
||||
; EAX = value
|
||||
; Output:
|
||||
; EAX = value MOD 624
|
||||
; --------------------------------------------------------------------------
|
||||
align PROC_ALIGN
|
||||
TRandom_GetModulo624:
|
||||
push ecx edx
|
||||
mcZeroBits edx
|
||||
mov ecx, 624
|
||||
div ecx
|
||||
mov eax, edx
|
||||
pop edx ecx
|
||||
ret
|
||||
|
||||
; --------------------------------------------------------------------------
|
||||
virtual at 0
|
||||
loc8:
|
||||
.index INDEX ?
|
||||
.y UINT32 ?
|
||||
.size = $
|
||||
end virtual
|
||||
; --------------------------------------------------------------------------
|
||||
align PROC_ALIGN
|
||||
TRandom_Generate624:
|
||||
mcBeginLocals loc8.size
|
||||
;
|
||||
; i=0
|
||||
;
|
||||
mcZeroBits eax
|
||||
mcStoreLocal loc8.index, eax
|
||||
;
|
||||
; MT array
|
||||
;
|
||||
mov esi, [glb_pMersenne]
|
||||
|
||||
.calc_y:
|
||||
;
|
||||
; MT [(i+1) MOD 624]
|
||||
;
|
||||
mcLoadLocal eax, loc8.index
|
||||
inc eax
|
||||
call TRandom_GetModulo624
|
||||
mov ecx, [esi + eax*4]
|
||||
;
|
||||
; Get last 31 bits of ECX
|
||||
;
|
||||
and ecx, 7FFFFFFFh
|
||||
;
|
||||
; 32nd bit of MT [i]
|
||||
;
|
||||
mcLoadLocal eax, loc8.index
|
||||
mov edx, [esi + eax*4]
|
||||
and edx, 80000000h
|
||||
;
|
||||
; Combine them and store as Y
|
||||
;
|
||||
or edx, ecx
|
||||
mcStoreLocal loc8.y, edx
|
||||
;
|
||||
; MT [i] = MT [(i+397) MOD 624] xor (y >> 1)
|
||||
;
|
||||
mcLoadLocal eax, loc8.index
|
||||
add eax, 397
|
||||
call TRandom_GetModulo624
|
||||
mov ecx, [esi + eax*4]
|
||||
|
||||
shr edx, 1
|
||||
xor ecx, edx
|
||||
mcLoadLocal eax, loc8.index
|
||||
mov [esi + eax*4], ecx
|
||||
;
|
||||
; IF ((Y MOD 2) == 1) THEN MT [i] ^= 9908B0DFh
|
||||
;
|
||||
test [esp + loc8.y], 1
|
||||
jz .continue
|
||||
|
||||
xor dword [esi + eax*4], 9908B0DFh
|
||||
|
||||
.continue:
|
||||
inc [esp + loc8.index]
|
||||
cmp [esp + loc8.index], 623
|
||||
jbe .calc_y
|
||||
|
||||
mcEndLocals loc8.size
|
||||
ret
|
||||
|
||||
; --------------------------------------------------------------------------
|
||||
; Output:
|
||||
; EAX = next random value from a sequence
|
||||
; --------------------------------------------------------------------------
|
||||
align PROC_ALIGN
|
||||
TRandom_GetNextNumber:
|
||||
push ebx
|
||||
mov ebx, [glb_pMersenne]
|
||||
;
|
||||
; IF (index == 0) THEN generate next 624 values
|
||||
;
|
||||
cmp [ebx + TRandom.rand_NextIndex], 0
|
||||
jne .get_it
|
||||
|
||||
push esi
|
||||
call TRandom_Generate624
|
||||
pop esi
|
||||
mov ebx, [glb_pMersenne]
|
||||
|
||||
.get_it:
|
||||
mcLoadMember ecx, TRandom.rand_NextIndex
|
||||
mov eax, [ebx + ecx*4]
|
||||
|
||||
mov edx, eax
|
||||
shr edx, 11
|
||||
xor eax, edx
|
||||
|
||||
mov edx, eax
|
||||
shl edx, 7
|
||||
and edx, 9D2C5680h
|
||||
xor eax, edx
|
||||
|
||||
mov edx, eax
|
||||
shl edx, 15
|
||||
and edx, 0EFC60000h
|
||||
xor eax, edx
|
||||
|
||||
mov edx, eax
|
||||
shr edx, 18
|
||||
xor eax, edx
|
||||
;
|
||||
; Index = (Index+1) MOD 624
|
||||
;
|
||||
push eax
|
||||
mov eax, ecx
|
||||
call TRandom_GetModulo624
|
||||
mcStoreMember TRandom.rand_NextIndex, eax
|
||||
pop eax
|
||||
pop ebx
|
||||
ret
|
||||
|
||||
; --------------------------------------------------------------------------
|
||||
; Input:
|
||||
; EDX = N
|
||||
; Output:
|
||||
; EAX = random value in range [0..N-1]
|
||||
; --------------------------------------------------------------------------
|
||||
align PROC_ALIGN
|
||||
TRandom_IRan:
|
||||
push edx
|
||||
call TRandom_GetNextNumber
|
||||
mcZeroBits edx
|
||||
pop ecx
|
||||
div ecx
|
||||
mov eax, edx
|
||||
ret
|
||||
|
||||
; --------------------------------------------------------------------------
|
||||
; Output:
|
||||
; ST(0) = random value in range [0..1]
|
||||
; --------------------------------------------------------------------------
|
||||
virtual at 0
|
||||
loc9:
|
||||
.dbl_2e31 DOUBLE ?
|
||||
.dbl_padded DOUBLE ?
|
||||
.size = $
|
||||
end virtual
|
||||
; --------------------------------------------------------------------------
|
||||
align PROC_ALIGN
|
||||
TRandom_Ranf:
|
||||
pushad
|
||||
mcBeginLocals loc9.size
|
||||
|
||||
fldz
|
||||
fstp [esp + loc9.dbl_2e31]
|
||||
|
||||
call TRandom_GetNextNumber
|
||||
test eax, 80000000h
|
||||
jz .add_two_parts
|
||||
|
||||
fld [glb_dbl_2e31]
|
||||
fstp [esp + loc9.dbl_2e31]
|
||||
and eax, 7FFFFFFFh
|
||||
|
||||
.add_two_parts:
|
||||
call TCommon_FPU_Load_EAX
|
||||
fld [esp + loc9.dbl_2e31]
|
||||
faddp
|
||||
|
||||
fld [glb_dbl_2e32]
|
||||
fdivp
|
||||
|
||||
mcEndLocals loc9.size
|
||||
popad
|
||||
ret
|
||||
|
||||
; --------------------------------------------------------------------------
|
||||
; Output:
|
||||
; EAX = value 1 or 10 (X,Y sector of Tholian!)
|
||||
; --------------------------------------------------------------------------
|
||||
align PROC_ALIGN
|
||||
TRandom_TholianSect:
|
||||
call TRandom_Ranf
|
||||
fld [glb_dbl_0dot5]
|
||||
faddp
|
||||
call TCommon_FP_Truncate
|
||||
imul eax, 9
|
||||
inc eax
|
||||
ret
|
||||
|
||||
; --------------------------------------------------------------------------
|
||||
; Output:
|
||||
; EAX = random X value in range [1..8]
|
||||
; EDX = random Y value in range [1..8]
|
||||
; --------------------------------------------------------------------------
|
||||
align PROC_ALIGN
|
||||
TRandom_IRan8:
|
||||
mcLoad8bitsToReg32 edx, 8
|
||||
call TRandom_IRan
|
||||
inc eax
|
||||
push eax
|
||||
|
||||
mcLoad8bitsToReg32 edx, 8
|
||||
call TRandom_IRan
|
||||
inc eax
|
||||
|
||||
mov edx, eax
|
||||
pop eax
|
||||
ret
|
||||
|
||||
; --------------------------------------------------------------------------
|
||||
; Output:
|
||||
; EAX = random X value in range [1..10]
|
||||
; EDX = random Y value in range [1..10]
|
||||
; --------------------------------------------------------------------------
|
||||
align PROC_ALIGN
|
||||
TRandom_IRan10:
|
||||
mcLoad8bitsToReg32 edx, 10
|
||||
call TRandom_IRan
|
||||
inc eax
|
||||
push eax
|
||||
|
||||
mcLoad8bitsToReg32 edx, 10
|
||||
call TRandom_IRan
|
||||
inc eax
|
||||
|
||||
mov edx, eax
|
||||
pop eax
|
||||
ret
|
||||
|
||||
; --- EOF ---
|
13
programs/games/StarTrek/trunk/TRandom.Inc
Normal file
13
programs/games/StarTrek/trunk/TRandom.Inc
Normal file
@ -0,0 +1,13 @@
|
||||
; --------------------------------------------------------------------------
|
||||
; FILE: TRandom.Inc
|
||||
; DATE: October 4, 2008
|
||||
; --------------------------------------------------------------------------
|
||||
|
||||
virtual at 0
|
||||
TRandom:
|
||||
.rand_NumberSet INTEGERS 624
|
||||
.rand_NextIndex INT32 ?
|
||||
.size = $
|
||||
end virtual
|
||||
|
||||
; --- EOF ---
|
314
programs/games/StarTrek/trunk/TShields.Asm
Normal file
314
programs/games/StarTrek/trunk/TShields.Asm
Normal file
@ -0,0 +1,314 @@
|
||||
; --------------------------------------------------------------------------
|
||||
; FILE: TShields.Asm
|
||||
; DATE: October 18, 2008
|
||||
; --------------------------------------------------------------------------
|
||||
|
||||
; --------------------------------------------------------------------------
|
||||
; SHIELDS
|
||||
; --------------------------------------------------------------------------
|
||||
virtual at 0
|
||||
loc35:
|
||||
.pTrekData PVOID ?
|
||||
.dbl_ETRANS DOUBLE ?
|
||||
.dbl_reserved DOUBLE ?
|
||||
.size = $
|
||||
end virtual
|
||||
; --------------------------------------------------------------------------
|
||||
align PROC_ALIGN
|
||||
TShields_Main:
|
||||
mcBeginLocals loc35.size
|
||||
mcLoadGameDataPtr ebx
|
||||
mcStoreLocal loc35.pTrekData, ebx
|
||||
|
||||
mov [ebx + TREKDATA.IDIDIT], 0
|
||||
call TCmdBuf_Scan
|
||||
|
||||
cmp [ebx + TCmdBuf.cmdbuf_KEY], CMD_TOKEN_EOL
|
||||
jne TShields_Up.L30
|
||||
|
||||
.L15:
|
||||
mcLoad8bitsToReg32 ecx, 225
|
||||
call TGame_JA
|
||||
jc TShields_Up.L8010
|
||||
|
||||
mov cl, DEV_SHIELDS
|
||||
call TArray_IsDamaged
|
||||
jc TShields_Up.L60
|
||||
|
||||
mcLoadLocal esi, loc35.pTrekData
|
||||
cmp [esi + TREKDATA.SHLDUP], 0
|
||||
jne TShields_Up.L20
|
||||
jmp TShields_Up.ENTRY
|
||||
|
||||
; --------------------------------------------------------------------------
|
||||
; SHLDSUP
|
||||
; --------------------------------------------------------------------------
|
||||
align PROC_ALIGN
|
||||
TShields_Up:
|
||||
mcBeginLocals loc35.size
|
||||
mcLoadGameDataPtr ebx
|
||||
mcStoreLocal loc35.pTrekData, ebx
|
||||
|
||||
.ENTRY:
|
||||
mcLoad8bitsToReg32 ecx, 226
|
||||
call TGame_JA
|
||||
jc .L40
|
||||
jmp .L90
|
||||
|
||||
.L20:
|
||||
mcLoad8bitsToReg32 ecx, 227
|
||||
call TGame_JA
|
||||
jc .L50
|
||||
jmp .L90
|
||||
|
||||
.L30:
|
||||
mcLoad8bitsToReg32 ecx, 244
|
||||
call TCmdBuf_Crop
|
||||
jc .L80
|
||||
|
||||
mov cl, DEV_SHIELDS
|
||||
call TArray_IsDamaged
|
||||
jc .L60
|
||||
|
||||
mcLoad8bitsToReg32 ecx, 245
|
||||
call TCmdBuf_Crop
|
||||
jc .L40
|
||||
|
||||
mcLoad8bitsToReg32 ecx, 246
|
||||
call TCmdBuf_Crop
|
||||
jc .L50
|
||||
jmp TShields_Main.L15
|
||||
|
||||
.L40:
|
||||
;
|
||||
; Raising shields
|
||||
;
|
||||
mcLoadLocal esi, loc35.pTrekData
|
||||
cmp [esi + TREKDATA.SHLDUP], 0
|
||||
jne .L45
|
||||
|
||||
mov [esi + TREKDATA.SHLDUP], 1
|
||||
mov [esi + TREKDATA.SHLDCHG], 1
|
||||
|
||||
cmp [esi + TREKDATA.CONDIT], CONDITION_DOCKED
|
||||
je .L401
|
||||
|
||||
fld [esi + TREKDATA.ENERGY]
|
||||
fld [glb_dbl_50]
|
||||
fsubp
|
||||
fstp [esi + TREKDATA.ENERGY]
|
||||
|
||||
.L401:
|
||||
call TConsole_SetGameMsgAttr
|
||||
mcLoad8bitsToReg32 ecx, 228
|
||||
call TConsole_Prout
|
||||
|
||||
mcLoadLocal esi, loc35.pTrekData
|
||||
fldz
|
||||
fld [esi + TREKDATA.ENERGY]
|
||||
mc_CMP_ST0_ST1
|
||||
jc .L70
|
||||
|
||||
.did_it:
|
||||
mcLoadLocal edi, loc35.pTrekData
|
||||
inc [edi + TREKDATA.IDIDIT]
|
||||
jmp .done
|
||||
|
||||
.L45:
|
||||
call TConsole_SetGameMsgAttr
|
||||
mcLoad8bitsToReg32 ecx, 230
|
||||
call TConsole_Prout
|
||||
jmp .done
|
||||
|
||||
.L50:
|
||||
;
|
||||
; Lowering shields
|
||||
;
|
||||
mcLoadLocal esi, loc35.pTrekData
|
||||
cmp [esi + TREKDATA.SHLDUP], 0
|
||||
je .L55
|
||||
|
||||
dec [esi + TREKDATA.SHLDUP]
|
||||
mov [esi + TREKDATA.SHLDCHG], 1
|
||||
|
||||
call TConsole_SetGameMsgAttr
|
||||
mcLoad8bitsToReg32 ecx, 229
|
||||
call TConsole_Prout
|
||||
jmp .did_it
|
||||
|
||||
.L55:
|
||||
call TConsole_SetGameMsgAttr
|
||||
mcLoad8bitsToReg32 ecx, 231
|
||||
call TConsole_Prout
|
||||
jmp .done
|
||||
|
||||
.L60:
|
||||
call TConsole_SetGameMsgAttr
|
||||
mcLoad8bitsToReg32 ecx, 232
|
||||
call TConsole_Prout
|
||||
jmp .done
|
||||
|
||||
.L70:
|
||||
call TConsole_ScrollUp
|
||||
call TConsole_SetGameMsgAttr
|
||||
mcLoad8bitsToReg32 ecx, 233
|
||||
call TConsole_Prout
|
||||
mov al, 4
|
||||
call TFinish_Main
|
||||
jmp .done
|
||||
|
||||
.L80:
|
||||
call TCmdBuf_Scan
|
||||
fld [ebx + TCmdBuf.cmdbuf_FNUM]
|
||||
fstp [esp + loc35.dbl_ETRANS]
|
||||
|
||||
cmp [ebx + TCmdBuf.cmdbuf_KEY], CMD_TOKEN_REAL
|
||||
je .L81
|
||||
|
||||
.L8010:
|
||||
mcLoad8bitsToReg32 ecx, 234
|
||||
call TGame_Prompt
|
||||
jmp .L80
|
||||
|
||||
.L81:
|
||||
fld [esp + loc35.dbl_ETRANS]
|
||||
fldz
|
||||
mc_CMP_ST0_ST1
|
||||
jz .L90
|
||||
|
||||
mcLoadLocal esi, loc35.pTrekData
|
||||
fld [esi + TREKDATA.ENERGY]
|
||||
fld [esp + loc35.dbl_ETRANS]
|
||||
mc_CMP_ST0_ST1
|
||||
jc .L82
|
||||
|
||||
call TConsole_SetGameMsgAttr
|
||||
mcLoad8bitsToReg32 ecx, 235
|
||||
call TConsole_Prout
|
||||
jmp .L90
|
||||
|
||||
.L82:
|
||||
mcLoadLocal edi, loc35.pTrekData
|
||||
inc [edi + TREKDATA.IDIDIT]
|
||||
|
||||
fld [edi + TREKDATA.INSHLD]
|
||||
fld [edi + TREKDATA.SHLD]
|
||||
fld [esp + loc35.dbl_ETRANS]
|
||||
faddp
|
||||
mc_CMP_ST0_ST1
|
||||
jc .L83
|
||||
jz .L83
|
||||
|
||||
call TConsole_SetGameMsgAttr
|
||||
mcLoad8bitsToReg32 ecx, 236
|
||||
call TConsole_Prout
|
||||
mcLoad8bitsToReg32 ecx, 237
|
||||
call TConsole_Prout
|
||||
|
||||
mcLoadLocal esi, loc35.pTrekData
|
||||
fld [esi + TREKDATA.SHLD]
|
||||
fld [esi + TREKDATA.INSHLD]
|
||||
fsubp
|
||||
fld [esi + TREKDATA.ENERGY]
|
||||
faddp
|
||||
fstp [esi + TREKDATA.ENERGY]
|
||||
|
||||
fld [esi + TREKDATA.INSHLD]
|
||||
fstp [esi + TREKDATA.SHLD]
|
||||
jmp .L90
|
||||
|
||||
.L83:
|
||||
fld [esp + loc35.dbl_ETRANS]
|
||||
fldz
|
||||
mc_CMP_ST0_ST1
|
||||
jc .L8310
|
||||
|
||||
mcLoadLocal esi, loc35.pTrekData
|
||||
fld [esi + TREKDATA.INENRG]
|
||||
fld [esi + TREKDATA.ENERGY]
|
||||
fld [esp + loc35.dbl_ETRANS]
|
||||
fsubp
|
||||
mc_CMP_ST0_ST1
|
||||
jc .L8310
|
||||
jz .L8310
|
||||
|
||||
fld [esi + TREKDATA.INENRG]
|
||||
fld [esi + TREKDATA.ENERGY]
|
||||
fld [esi + TREKDATA.SHLD]
|
||||
faddp
|
||||
mc_CMP_ST0_ST1
|
||||
jc .L8310
|
||||
jz .L8310
|
||||
|
||||
call TConsole_SetCrewMsgAttr
|
||||
call TConsole_ScrollUp
|
||||
mcLoad8bitsToReg32 ecx, 148
|
||||
call TConsole_Prout
|
||||
mcLoad8bitsToReg32 ecx, 238
|
||||
call TConsole_Prout
|
||||
mcLoad8bitsToReg32 ecx, 239
|
||||
call TConsole_Prout
|
||||
|
||||
mcLoadLocal edi, loc35.pTrekData
|
||||
dec [edi + TREKDATA.IDIDIT]
|
||||
jmp .L90
|
||||
|
||||
.L8310:
|
||||
mcLoadLocal esi, loc35.pTrekData
|
||||
fld [esi + TREKDATA.SHLD]
|
||||
fld [esp + loc35.dbl_ETRANS]
|
||||
faddp
|
||||
fldz
|
||||
mc_CMP_ST0_ST1
|
||||
jc .L84
|
||||
jz .L84
|
||||
|
||||
call TConsole_SetGameMsgAttr
|
||||
mcLoad8bitsToReg32 ecx, 240
|
||||
call TConsole_Prout
|
||||
|
||||
mcLoadLocal esi, loc35.pTrekData
|
||||
fld [esi + TREKDATA.ENERGY]
|
||||
fld [esi + TREKDATA.SHLD]
|
||||
faddp
|
||||
fstp [esi + TREKDATA.ENERGY]
|
||||
|
||||
fldz
|
||||
fstp [esi + TREKDATA.SHLD]
|
||||
jmp .L90
|
||||
|
||||
.L84:
|
||||
call TConsole_SetCrewMsgAttr
|
||||
mcLoad8bitsToReg32 ecx, 242
|
||||
mcLoad8bitsToReg32 edx, 243
|
||||
fld [esp + loc35.dbl_ETRANS]
|
||||
fldz
|
||||
mc_CMP_ST0_ST1
|
||||
cmovnc ecx, edx
|
||||
call TConsole_Prout
|
||||
|
||||
mcLoadLocal ebx, loc35.pTrekData
|
||||
fld [ebx + TREKDATA.SHLD]
|
||||
fld [esp + loc35.dbl_ETRANS]
|
||||
faddp
|
||||
fstp [ebx + TREKDATA.SHLD]
|
||||
|
||||
fld [ebx + TREKDATA.ENERGY]
|
||||
fld [esp + loc35.dbl_ETRANS]
|
||||
fsubp
|
||||
fstp [ebx + TREKDATA.ENERGY]
|
||||
|
||||
.L90:
|
||||
mcLoadLocal esi, loc35.pTrekData
|
||||
fld [esi + TREKDATA.SHLD]
|
||||
fldz
|
||||
mc_CMP_ST0_ST1
|
||||
jc .done
|
||||
|
||||
dec [esi + TREKDATA.SHLDUP]
|
||||
|
||||
.done:
|
||||
mcEndLocals loc35.size
|
||||
ret
|
||||
|
||||
; --- EOF ---
|
519
programs/games/StarTrek/trunk/TSrScan.Asm
Normal file
519
programs/games/StarTrek/trunk/TSrScan.Asm
Normal file
@ -0,0 +1,519 @@
|
||||
; --------------------------------------------------------------------------
|
||||
; FILE: TSrScan.Asm
|
||||
; DATE: October 11, 2008
|
||||
; --------------------------------------------------------------------------
|
||||
|
||||
; --------------------------------------------------------------------------
|
||||
; Input:
|
||||
; AL = character from QUAD array
|
||||
; --------------------------------------------------------------------------
|
||||
align PROC_ALIGN
|
||||
TSrScan_SetCosmosAttr:
|
||||
push ecx
|
||||
|
||||
mcOnRegEqu al, CHAR_ASTERISK, .attr_star
|
||||
mcOnRegEqu al, CHAR_BLACK_HOLE, .attr_bhole
|
||||
mcOnRegEqu al, CHAR_COMMANDER, .attr_klingon
|
||||
mcOnRegEqu al, CHAR_ENTERPRISE, .attr_ship
|
||||
mcOnRegEqu al, CHAR_FQUEENE, .attr_ship
|
||||
mcOnRegEqu al, CHAR_KLINGON, .attr_klingon
|
||||
mcOnRegEqu al, CHAR_PLANET, .attr_planet
|
||||
mcOnRegEqu al, CHAR_ROMULAN, .attr_romulan
|
||||
mcOnRegEqu al, CHAR_SCOM, .attr_klingon
|
||||
mcOnRegEqu al, CHAR_STARBASE, .attr_base
|
||||
mcOnRegEqu al, CHAR_THING, .attr_thing
|
||||
mcOnRegEqu al, CHAR_THOLIAN, .attr_tholian
|
||||
mcOnRegEqu al, CHAR_WEB, .attr_web
|
||||
|
||||
mov cl, ATTR_COSMOS
|
||||
jmp .apply
|
||||
|
||||
.attr_star:
|
||||
mov cl, ATTR_STAR
|
||||
jmp .apply
|
||||
|
||||
.attr_bhole:
|
||||
mov cl, ATTR_BLACK_HOLE
|
||||
jmp .apply
|
||||
|
||||
.attr_klingon:
|
||||
mov cl, ATTR_KLINGON
|
||||
jmp .apply
|
||||
|
||||
.attr_ship:
|
||||
mov cl, ATTR_SHIP
|
||||
jmp .apply
|
||||
|
||||
.attr_planet:
|
||||
mov cl, ATTR_PLANET
|
||||
jmp .apply
|
||||
|
||||
.attr_romulan:
|
||||
mov cl, ATTR_ROMULAN
|
||||
jmp .apply
|
||||
|
||||
.attr_base:
|
||||
mov cl, ATTR_BASE
|
||||
jmp .apply
|
||||
|
||||
.attr_thing:
|
||||
mov cl, ATTR_BLACK_HOLE
|
||||
jmp .apply
|
||||
|
||||
.attr_tholian:
|
||||
mov cl, ATTR_THOLIAN
|
||||
jmp .apply
|
||||
|
||||
.attr_web:
|
||||
mov cl, ATTR_WEB
|
||||
|
||||
.apply:
|
||||
call TConsole_SetAttr
|
||||
pop ecx
|
||||
ret
|
||||
|
||||
; --------------------------------------------------------------------------
|
||||
; Input:
|
||||
; EAX = row index from 1 to 10
|
||||
; --------------------------------------------------------------------------
|
||||
align PROC_ALIGN
|
||||
TSrScan_CramSpaceRow:
|
||||
dec eax
|
||||
imul eax, 10
|
||||
|
||||
mcLoadGameDataPtr edx
|
||||
lea esi, [edx + eax + TREKDATA.QUAD]
|
||||
mcLoad8bitsToReg32 ecx, 10
|
||||
|
||||
.dump_sector:
|
||||
push ecx
|
||||
|
||||
lodsb
|
||||
call TSrScan_SetCosmosAttr
|
||||
call TConsole_PutChar
|
||||
mov al, CHAR_BLANK
|
||||
call TConsole_PutChar
|
||||
|
||||
pop ecx
|
||||
loop .dump_sector
|
||||
ret
|
||||
|
||||
; --------------------------------------------------------------------------
|
||||
; Input:
|
||||
; ECX = index of SRSCAN report item text
|
||||
; --------------------------------------------------------------------------
|
||||
align PROC_ALIGN
|
||||
TSrScan_Helper1:
|
||||
call TConsole_Cram
|
||||
mov cl, ATTR_REPORT_VALUE
|
||||
call TConsole_SetAttr
|
||||
mcLoadGameDataPtr ebx
|
||||
ret
|
||||
|
||||
; --------------------------------------------------------------------------
|
||||
align PROC_ALIGN
|
||||
TSrScan_PrintTubesInfo:
|
||||
mov ecx, 705
|
||||
call TConsole_Cram
|
||||
|
||||
mcLoadGameDataPtr esi
|
||||
movzx eax, [esi + TREKDATA.NPTUBES]
|
||||
call TConsole_CramInt
|
||||
|
||||
mcLoadGameDataPtr esi
|
||||
cmp [esi + TREKDATA.QTORPS], 0
|
||||
je .close_bracket
|
||||
cmp [esi + TREKDATA.TORPS], 0
|
||||
je .close_bracket
|
||||
|
||||
mov ecx, 706
|
||||
call TConsole_Cram
|
||||
|
||||
.close_bracket:
|
||||
mov al, ')'
|
||||
call TConsole_PutChar
|
||||
ret
|
||||
|
||||
; --------------------------------------------------------------------------
|
||||
; Input:
|
||||
; EAX = row index from 1 to 10
|
||||
; --------------------------------------------------------------------------
|
||||
align PROC_ALIGN
|
||||
TSrScan_CramStatusRow:
|
||||
mov cl, ATTR_REPORT_TEXT
|
||||
call TConsole_SetAttr
|
||||
|
||||
mcOnRegEqu eax, 1, .print_stardate
|
||||
mcOnRegEqu eax, 2, .print_condition
|
||||
mcOnRegEqu eax, 3, .print_position
|
||||
mcOnRegEqu eax, 4, .print_lsupport
|
||||
mcOnRegEqu eax, 5, .print_warp
|
||||
mcOnRegEqu eax, 6, .print_energy
|
||||
mcOnRegEqu eax, 7, .print_torpedoes
|
||||
mcOnRegEqu eax, 8, .print_shields
|
||||
mcOnRegEqu eax, 9, .print_klingons
|
||||
;
|
||||
; Time left
|
||||
;
|
||||
mcLoad8bitsToReg32 ecx, 103
|
||||
call TSrScan_Helper1
|
||||
|
||||
fld [ebx + TREKDATA.REMTIME]
|
||||
mov cl, 2
|
||||
call TConsole_CramFloat
|
||||
jmp .done
|
||||
|
||||
.print_stardate:
|
||||
mcLoad8bitsToReg32 ecx, 94
|
||||
call TSrScan_Helper1
|
||||
|
||||
fld [ebx + TREKDATA.DATE]
|
||||
mov cl, 1
|
||||
call TConsole_CramFloat
|
||||
jmp .done
|
||||
|
||||
.print_condition:
|
||||
mcLoad8bitsToReg32 ecx, 95
|
||||
call TSrScan_Helper1
|
||||
|
||||
cmp [ebx + TREKDATA.CONDIT], CONDITION_DOCKED
|
||||
je .do_condition
|
||||
|
||||
push ebx
|
||||
call TCommon_NewCondition
|
||||
pop ebx
|
||||
|
||||
.do_condition:
|
||||
movzx eax, [ebx + TREKDATA.CONDIT]
|
||||
mov esi, glb_AttrCondition
|
||||
mov cl, [esi + eax - 1]
|
||||
call TConsole_SetAttr
|
||||
|
||||
lea ecx, [eax + 103]
|
||||
call TConsole_Cram
|
||||
jmp .done
|
||||
|
||||
.print_position:
|
||||
mcLoad8bitsToReg32 ecx, 96
|
||||
call TSrScan_Helper1
|
||||
|
||||
mov al, [ebx + TREKDATA.QUADX]
|
||||
mov dl, [ebx + TREKDATA.QUADY]
|
||||
mcZeroBits ecx
|
||||
push ebx
|
||||
call TConsole_CramLoc
|
||||
|
||||
mov al, ','
|
||||
call TConsole_PutChar
|
||||
pop ebx
|
||||
|
||||
mov al, [ebx + TREKDATA.SECTX]
|
||||
mov dl, [ebx + TREKDATA.SECTY]
|
||||
mcZeroBits ecx
|
||||
call TConsole_CramLoc
|
||||
jmp .done
|
||||
|
||||
.print_lsupport:
|
||||
mcLoad8bitsToReg32 ecx, 97
|
||||
call TSrScan_Helper1
|
||||
|
||||
mov cl, DEV_LIFE_SUPPORT
|
||||
call TArray_IsDamaged
|
||||
jc .L44
|
||||
|
||||
mcLoad8bitsToReg32 ecx, 108
|
||||
call TConsole_Cram
|
||||
jmp .done
|
||||
|
||||
.L44:
|
||||
cmp [ebx + TREKDATA.CONDIT], CONDITION_DOCKED
|
||||
jne .L45
|
||||
|
||||
mcLoad8bitsToReg32 ecx, 109
|
||||
call TConsole_Cram
|
||||
jmp .done
|
||||
|
||||
.L45:
|
||||
mcLoad8bitsToReg32 ecx, 110
|
||||
push ebx
|
||||
call TConsole_Cram
|
||||
pop ebx
|
||||
|
||||
fld [ebx + TREKDATA.LSUPRES]
|
||||
mov cl, 2
|
||||
mov dl, 4
|
||||
call TConsole_CramFloatWidth
|
||||
jmp .done
|
||||
|
||||
.print_warp:
|
||||
mcLoad8bitsToReg32 ecx, 98
|
||||
call TSrScan_Helper1
|
||||
|
||||
fld [ebx + TREKDATA.WARPFAC]
|
||||
mov cl, 1
|
||||
call TConsole_CramFloat
|
||||
jmp .done
|
||||
|
||||
.print_energy:
|
||||
mcLoad8bitsToReg32 ecx, 99
|
||||
call TSrScan_Helper1
|
||||
|
||||
fld [ebx + TREKDATA.ENERGY]
|
||||
mov cl, 2
|
||||
call TConsole_CramFloat
|
||||
jmp .done
|
||||
|
||||
.print_torpedoes:
|
||||
mcLoad8bitsToReg32 ecx, 100
|
||||
call TSrScan_Helper1
|
||||
|
||||
movzx eax, [ebx + TREKDATA.TORPS]
|
||||
call TConsole_CramInt
|
||||
call TSrScan_PrintTubesInfo
|
||||
jmp .done
|
||||
|
||||
.print_shields:
|
||||
mcLoad8bitsToReg32 ecx, 101
|
||||
call TSrScan_Helper1
|
||||
|
||||
mov cl, DEV_SHIELDS
|
||||
call TArray_IsDamaged
|
||||
jc .shields_damaged
|
||||
|
||||
movzx ecx, [ebx + TREKDATA.SHLDUP]
|
||||
add cl, 120
|
||||
|
||||
.cram_shields_state:
|
||||
push ebx
|
||||
call TConsole_Cram
|
||||
pop ebx
|
||||
|
||||
fld [ebx + TREKDATA.SHLD]
|
||||
fld [ebx + TREKDATA.INSHLD]
|
||||
fdivp
|
||||
fld [glb_dbl_100]
|
||||
fmulp
|
||||
frndint
|
||||
call TCommon_FP_Truncate
|
||||
push ebx
|
||||
call TConsole_CramInt
|
||||
|
||||
mcLoad8bitsToReg32 ecx, 111
|
||||
call TConsole_Cram
|
||||
|
||||
pop ebx
|
||||
fld [ebx + TREKDATA.SHLD]
|
||||
frndint
|
||||
call TCommon_FP_Truncate
|
||||
call TConsole_CramInt
|
||||
|
||||
mcLoad8bitsToReg32 ecx, 112
|
||||
call TConsole_Cram
|
||||
jmp .done
|
||||
|
||||
.shields_damaged:
|
||||
mcLoad8bitsToReg32 ecx, 119
|
||||
jmp .cram_shields_state
|
||||
|
||||
.print_klingons:
|
||||
mcLoad8bitsToReg32 ecx, 102
|
||||
call TSrScan_Helper1
|
||||
|
||||
movzx eax, [ebx + TREKDATA.REMKL]
|
||||
call TConsole_CramInt
|
||||
|
||||
.done:
|
||||
ret
|
||||
|
||||
; --------------------------------------------------------------------------
|
||||
; STATUS
|
||||
; --------------------------------------------------------------------------
|
||||
align PROC_ALIGN
|
||||
TSrScan_Status:
|
||||
call TConsole_ScrollUp
|
||||
|
||||
mcLoad1 eax
|
||||
mcLoad8bitsToReg32 ecx, 10
|
||||
|
||||
.dump_row:
|
||||
push eax ecx
|
||||
|
||||
call TSrScan_CramStatusRow
|
||||
call TConsole_ScrollUp
|
||||
|
||||
pop ecx eax
|
||||
inc eax
|
||||
loop .dump_row
|
||||
|
||||
call TConsole_ScrollUp
|
||||
ret
|
||||
|
||||
; --------------------------------------------------------------------------
|
||||
; REQUEST
|
||||
; --------------------------------------------------------------------------
|
||||
align PROC_ALIGN
|
||||
TSrScan_Request:
|
||||
|
||||
.L301:
|
||||
call TCmdBuf_Scan
|
||||
cmp [ebx + TCmdBuf.cmdbuf_KEY], CMD_TOKEN_ALPHA
|
||||
je .L303
|
||||
|
||||
.L302:
|
||||
mcLoad8bitsToReg32 ecx, 115
|
||||
call TGame_Prompt
|
||||
jmp .L301
|
||||
|
||||
.L303:
|
||||
mcLoad8bitsToReg32 edx, 1
|
||||
|
||||
.check_cmd:
|
||||
mcLoad8bitsToReg32 ecx, 122
|
||||
add ecx, edx
|
||||
push edx
|
||||
call TCmdBuf_Crop
|
||||
pop edx
|
||||
jc .row_in_EDX
|
||||
|
||||
inc edx
|
||||
cmp edx, 10
|
||||
jbe .check_cmd
|
||||
;
|
||||
; List possible request items
|
||||
;
|
||||
call TConsole_ScrollUp
|
||||
call TConsole_SetGameMsgAttr
|
||||
mcLoad8bitsToReg32 ecx, 116
|
||||
call TConsole_Prout
|
||||
mcLoad8bitsToReg32 ecx, 117
|
||||
call TConsole_Prout
|
||||
mcLoad8bitsToReg32 ecx, 118
|
||||
call TConsole_Prout
|
||||
call TConsole_ScrollUp
|
||||
jmp .L302
|
||||
|
||||
.row_in_EDX:
|
||||
push edx
|
||||
call TConsole_ScrollUp
|
||||
pop eax
|
||||
;
|
||||
; Due to mapping we need to swap places of
|
||||
; TIME and TORPEDOES request. Basic logic here as follows:
|
||||
;
|
||||
; IF (EAX == 7) THEN EAX=10
|
||||
; IF (EAX == 10) THEN EAX=7
|
||||
;
|
||||
mcOnRegEqu eax, 7, .load_10
|
||||
mcOnRegEqu eax, 10, .load_7
|
||||
|
||||
.dump_info:
|
||||
call TSrScan_CramStatusRow
|
||||
call TConsole_ScrollUp
|
||||
call TConsole_ScrollUp
|
||||
ret
|
||||
|
||||
.load_7:
|
||||
sub eax, 3
|
||||
jmp .dump_info
|
||||
|
||||
.load_10:
|
||||
add eax, 3
|
||||
jmp .dump_info
|
||||
|
||||
; --------------------------------------------------------------------------
|
||||
; SRSCAN
|
||||
; --------------------------------------------------------------------------
|
||||
virtual at 0
|
||||
loc24:
|
||||
.bRightSide BOOL ?
|
||||
.nRow INDEX ?
|
||||
.size = $
|
||||
end virtual
|
||||
; --------------------------------------------------------------------------
|
||||
align PROC_ALIGN
|
||||
TSrScan_Main:
|
||||
mcBeginLocals loc24.size
|
||||
|
||||
mov cl, DEV_SR_SENSORS
|
||||
call TArray_IsDamaged
|
||||
jnc .proceed
|
||||
|
||||
mcLoadGameDataPtr ebx
|
||||
cmp [ebx + TREKDATA.CONDIT], CONDITION_DOCKED
|
||||
jne .not_available
|
||||
|
||||
.proceed:
|
||||
mcLoad1 eax
|
||||
mcStoreLocal loc24.bRightSide, eax
|
||||
mcStoreLocal loc24.nRow, eax
|
||||
|
||||
call TCmdBuf_Scan
|
||||
cmp [ebx + TCmdBuf.cmdbuf_KEY], CMD_TOKEN_EOL
|
||||
je .L3
|
||||
|
||||
mcLoad8bitsToReg32 ecx, 122
|
||||
call TCmdBuf_Crop
|
||||
jnc .L3
|
||||
|
||||
dec [esp + loc24.bRightSide]
|
||||
|
||||
.L3:
|
||||
mcLoadLocal ecx, loc24.nRow
|
||||
mcLoadGameDataPtr ebx
|
||||
mcLoadMember al, TREKDATA.QUADX
|
||||
mcLoadMember dl, TREKDATA.QUADY
|
||||
call TArray_SetStarChartValue
|
||||
call TArray_SetScanned
|
||||
|
||||
call TConsole_ScrollUp
|
||||
|
||||
mov cl, ATTR_SCAN_SCALE
|
||||
call TConsole_SetAttr
|
||||
mcLoad8bitsToReg32 ecx, 113
|
||||
call TConsole_Prout
|
||||
|
||||
.dump_row:
|
||||
mov cl, ATTR_SCAN_SCALE
|
||||
call TConsole_SetAttr
|
||||
|
||||
mcLoadLocal eax, loc24.nRow
|
||||
mov cl, 3
|
||||
call TConsole_CramIntWidth
|
||||
|
||||
mov al, CHAR_BLANK
|
||||
call TConsole_PutChar
|
||||
|
||||
mcLoadLocal eax, loc24.nRow
|
||||
call TSrScan_CramSpaceRow
|
||||
|
||||
cmp [esp + loc24.bRightSide], 0
|
||||
je .next_row
|
||||
|
||||
mcLoadLocal eax, loc24.nRow
|
||||
call TSrScan_CramStatusRow
|
||||
|
||||
.next_row:
|
||||
call TConsole_ScrollUp
|
||||
|
||||
inc [esp + loc24.nRow]
|
||||
cmp [esp + loc24.nRow], 10
|
||||
jbe .dump_row
|
||||
|
||||
mov cl, ATTR_SCAN_SCALE
|
||||
call TConsole_SetAttr
|
||||
mcLoad8bitsToReg32 ecx, 113
|
||||
call TConsole_Prout
|
||||
jmp .done
|
||||
|
||||
.not_available:
|
||||
call TConsole_SetGameMsgAttr
|
||||
call TConsole_ScrollUp
|
||||
mcLoad8bitsToReg32 ecx, 114
|
||||
call TConsole_Prout
|
||||
|
||||
.done:
|
||||
call TConsole_ScrollUp
|
||||
mcEndLocals loc24.size
|
||||
ret
|
||||
|
||||
; --- EOF ---
|
78
programs/games/StarTrek/trunk/TString.Asm
Normal file
78
programs/games/StarTrek/trunk/TString.Asm
Normal file
@ -0,0 +1,78 @@
|
||||
; --------------------------------------------------------------------------
|
||||
; FILE: TString.Asm
|
||||
; DATE: September 21, 2008
|
||||
; --------------------------------------------------------------------------
|
||||
|
||||
; --------------------------------------------------------------------------
|
||||
; Input:
|
||||
; ESI = source string
|
||||
; EDI = destination string
|
||||
; --------------------------------------------------------------------------
|
||||
align PROC_ALIGN
|
||||
TString_Copy:
|
||||
mcZeroBits eax
|
||||
|
||||
.more:
|
||||
lodsw
|
||||
stosw
|
||||
mcOnRegNotZero eax, .more
|
||||
|
||||
ret
|
||||
|
||||
; --------------------------------------------------------------------------
|
||||
; Input:
|
||||
; ESI = source string
|
||||
; EDI = destination string
|
||||
; --------------------------------------------------------------------------
|
||||
align PROC_ALIGN
|
||||
TString_AnsiCopy:
|
||||
mcZeroBits eax
|
||||
|
||||
.more:
|
||||
lodsb
|
||||
stosb
|
||||
mcOnRegNotZero eax, .more
|
||||
|
||||
ret
|
||||
|
||||
; --------------------------------------------------------------------------
|
||||
; Input:
|
||||
; ESI = string #1
|
||||
; EDI = string #2
|
||||
; Output:
|
||||
; CF=1 if strings are same
|
||||
; --------------------------------------------------------------------------
|
||||
align PROC_ALIGN
|
||||
TString_AnsiEqual:
|
||||
push esi edi
|
||||
|
||||
.check_both:
|
||||
cmpsb
|
||||
jne .ret_false
|
||||
|
||||
cmp byte [esi - 1], 0
|
||||
jne .check_both
|
||||
|
||||
pop edi esi
|
||||
stc
|
||||
ret
|
||||
|
||||
.ret_false:
|
||||
pop edi esi
|
||||
clc
|
||||
ret
|
||||
|
||||
; --------------------------------------------------------------------------
|
||||
; Input:
|
||||
; ESI = source string
|
||||
; EDI = destination string
|
||||
; Output:
|
||||
; EDI = set to concatenate another string
|
||||
; --------------------------------------------------------------------------
|
||||
align PROC_ALIGN
|
||||
TString_CopyEx:
|
||||
call TString_Copy
|
||||
sub edi, 2
|
||||
ret
|
||||
|
||||
; --- EOF ---
|
255
programs/games/StarTrek/trunk/Win32.Inc
Normal file
255
programs/games/StarTrek/trunk/Win32.Inc
Normal file
@ -0,0 +1,255 @@
|
||||
; -----------------------------------------------------------
|
||||
; Win32 API definitions
|
||||
; -----------------------------------------------------------
|
||||
|
||||
; -----------------------------------------------------------
|
||||
; Type Alias Section
|
||||
; -----------------------------------------------------------
|
||||
|
||||
INT32 equ dd
|
||||
PINT32 equ dd
|
||||
INT16 equ dw
|
||||
SHORT equ dw
|
||||
WNDPROC equ dd
|
||||
COUNT equ dd
|
||||
UINT32 equ dd
|
||||
UINT8 equ db
|
||||
WORD equ dw
|
||||
BYTE equ db
|
||||
CHAR equ db
|
||||
PBYTE equ dd
|
||||
NBYTES equ dd
|
||||
HICON equ dd
|
||||
HBRUSH equ dd
|
||||
HBITMAP equ dd
|
||||
HCURSOR equ dd
|
||||
HINSTANCE equ dd
|
||||
PWCHAR equ dd
|
||||
PCHAR equ dd
|
||||
PPCHAR equ dd
|
||||
PDOUBLE equ dd
|
||||
PPWCHAR equ dd
|
||||
WCHARS equ rw
|
||||
CHARS equ rb
|
||||
HWND equ dd
|
||||
DOUBLE equ dt
|
||||
DOUBLES equ rt
|
||||
HANDLE equ dd
|
||||
HFILE equ dd
|
||||
HDC equ dd
|
||||
HFONT equ dd
|
||||
BOOL equ dd
|
||||
PBOOL equ dd
|
||||
LONG equ dd
|
||||
WPARAM equ dd
|
||||
LPARAM equ dd
|
||||
INDEX equ dd
|
||||
COLORREF equ dd
|
||||
PSIZE equ dd
|
||||
PVOID equ dd
|
||||
PCOORD equ dd
|
||||
FUNCTOR equ dd
|
||||
PDEVICE equ dd
|
||||
STRINGS equ rd
|
||||
INTEGERS equ rd
|
||||
POINTERS equ rd
|
||||
COLORREFS equ rd
|
||||
CHARS equ rb
|
||||
BYTES equ rb
|
||||
|
||||
; -----------------------------------------------------------
|
||||
; Pointers to classes
|
||||
; -----------------------------------------------------------
|
||||
|
||||
PTLine equ dd
|
||||
PTOutputCell equ dd
|
||||
PTCmdBuf equ dd
|
||||
PTRandom equ dd
|
||||
PTPalette equ dd
|
||||
PTGameState equ dd
|
||||
PTPlanet equ dd
|
||||
PTKlingon equ dd
|
||||
PTCharAttr equ dd
|
||||
PTLineBuf equ dd
|
||||
PTConsole equ dd
|
||||
PTCharacter equ dd
|
||||
|
||||
; -----------------------------------------------------------
|
||||
; Constants
|
||||
; -----------------------------------------------------------
|
||||
|
||||
HEAP_NO_SERIALIZE = 1
|
||||
DEFAULT_CHARSET = 1
|
||||
LF_FACESIZE = 32
|
||||
IDC_ARROW = 32512
|
||||
IDI_EXCLAMATION = 32515
|
||||
SM_CXSCREEN = 0
|
||||
SM_CYSCREEN = 1
|
||||
WS_EX_APPWINDOW = 40000h
|
||||
WS_THICKFRAME = 40000h
|
||||
WS_SYSMENU = 80000h
|
||||
WS_MINIMIZEBOX = 20000h
|
||||
WS_CAPTION = 0C00000h
|
||||
WS_OVERLAPPEDWND = WS_CAPTION or WS_SYSMENU or WS_THICKFRAME or WS_MINIMIZEBOX
|
||||
WS_NOSIZEWND = WS_CAPTION or WS_SYSMENU or WS_MINIMIZEBOX
|
||||
WM_CREATE = 1
|
||||
WM_DESTROY = 2
|
||||
WM_PAINT = 0Fh
|
||||
WM_CLOSE = 10h
|
||||
WM_ERASEBKGND = 14h
|
||||
WM_CHAR = 102h
|
||||
WM_APP = 8000h
|
||||
MEM_COMMIT = 1000h
|
||||
MEM_RESERVE = 2000h
|
||||
MEM_RELEASE = 8000h
|
||||
PAGE_READWRITE = 4
|
||||
SW_SHOWNORMAL = 1
|
||||
SM_CYCAPTION = 4
|
||||
SM_CXBORDER = 5
|
||||
SM_CYBORDER = 6
|
||||
LOGPIXELSY = 90
|
||||
FW_NORMAL = 400
|
||||
CHAR_BACKSPACE = 8
|
||||
CHAR_ENTER = 0Dh
|
||||
CHAR_ESC = 1Bh
|
||||
CHAR_BLANK = 20h
|
||||
CHAR_COSMOS = 0B7h
|
||||
;CHAR_COSMOS = '.'
|
||||
CHAR_ASTERISK = '*'
|
||||
CHAR_ENTERPRISE = 'E'
|
||||
CHAR_FQUEENE = 'F'
|
||||
CHAR_ZERO = '0'
|
||||
CHAR_PLANET = 'P'
|
||||
CHAR_KLINGON = 'K'
|
||||
CHAR_ROMULAN = 'R'
|
||||
CHAR_SCOM = 'S'
|
||||
CHAR_THOLIAN = 'T'
|
||||
CHAR_WEB = '#'
|
||||
CHAR_THING = '?'
|
||||
CHAR_STARBASE = 'B'
|
||||
CHAR_BLACK_HOLE = '@'
|
||||
CHAR_COMMA = ','
|
||||
CHAR_COMMANDER = 'C'
|
||||
SRCCOPY = 0CC0020h
|
||||
FIXED_PITCH = 1
|
||||
TRANSPARENT = 1
|
||||
TA_UPDATECP = 1
|
||||
WHITE_BRUSH = 0
|
||||
BLACK_BRUSH = 4
|
||||
WM_CUSTOM_CMD_READY = (WM_APP + 1)
|
||||
WM_CUSTOM_DO_PRELIM = (WM_APP + 2)
|
||||
WM_CUSTOM_NEW_GAME = (WM_APP + 3)
|
||||
GENERIC_READ = 80000000h
|
||||
GENERIC_WRITE = 40000000h
|
||||
CREATE_ALWAYS = 2
|
||||
OPEN_EXISTING = 3
|
||||
FILE_FLAG_SEQ_SCAN = 08000000h
|
||||
FILE_ATTR_DIR = 10h
|
||||
|
||||
; -----------------------------------------------------------
|
||||
; Structure Definitions
|
||||
; -----------------------------------------------------------
|
||||
|
||||
virtual at 0
|
||||
SIZE:
|
||||
.size_Width INT32 ?
|
||||
.size_Height INT32 ?
|
||||
.size = $
|
||||
end virtual
|
||||
|
||||
virtual at 0
|
||||
RECT:
|
||||
.rc_Left INT32 ?
|
||||
.rc_Top INT32 ?
|
||||
.rc_Right INT32 ?
|
||||
.rc_Bottom INT32 ?
|
||||
.size = $
|
||||
end virtual
|
||||
|
||||
virtual at 0
|
||||
MSG:
|
||||
.msg_hWnd HWND ?
|
||||
.msg_uiMsg UINT32 ?
|
||||
.msg_wParam WPARAM ?
|
||||
.msg_lParam LPARAM ?
|
||||
.msg_uiTime UINT32 ?
|
||||
.msg_xCoord INT32 ?
|
||||
.msg_yCoord INT32 ?
|
||||
.size = $
|
||||
end virtual
|
||||
|
||||
virtual at 0
|
||||
LOGFONT:
|
||||
.lf_Height LONG ?
|
||||
.lf_Width LONG ?
|
||||
.lf_Escapement LONG ?
|
||||
.lf_Orientation LONG ?
|
||||
.lf_Weight LONG ?
|
||||
.lf_Italic UINT8 ?
|
||||
.lf_Underline UINT8 ?
|
||||
.lf_StrikeOut UINT8 ?
|
||||
.lf_CharSet UINT8 ?
|
||||
.lf_OutPrecision UINT8 ?
|
||||
.lf_ClipPrecision UINT8 ?
|
||||
.lf_Quality UINT8 ?
|
||||
.lf_PitchAndFamily UINT8 ?
|
||||
.lf_FaceName WCHARS LF_FACESIZE
|
||||
.size = $
|
||||
end virtual
|
||||
|
||||
virtual at 0
|
||||
WIN32_FIND_DATA:
|
||||
.dwAttr UINT32 ?
|
||||
._pad1 rd 10
|
||||
.strName WCHARS 260
|
||||
.strName2 WCHARS 14
|
||||
.size = $
|
||||
end virtual
|
||||
|
||||
virtual at 0
|
||||
SYSTIME:
|
||||
.wYear WORD ?
|
||||
.wMonth WORD ?
|
||||
.wDayOfWeek WORD ?
|
||||
.wDay WORD ?
|
||||
.wHour WORD ?
|
||||
.wMinute WORD ?
|
||||
.wSecond WORD ?
|
||||
.wMillisecond WORD ?
|
||||
.size = $
|
||||
end virtual
|
||||
|
||||
virtual at 0
|
||||
PAINTSTRUCT:
|
||||
.hDC HDC ?
|
||||
.bErase BOOL ?
|
||||
.rcPaint rb RECT.size
|
||||
.bRestore BOOL ?
|
||||
.bIncUpdate BOOL ?
|
||||
.rgbReserved rb 32
|
||||
.size = $
|
||||
end virtual
|
||||
|
||||
virtual at 0
|
||||
LOCATION:
|
||||
.coord_X BYTE ?
|
||||
.coord_Y BYTE ?
|
||||
.size = $
|
||||
end virtual
|
||||
|
||||
virtual at 0
|
||||
WNDCLASS:
|
||||
.wc_style UINT32 ?
|
||||
.wc_lpfnWndProc WNDPROC ?
|
||||
.wc_cbClsExtra NBYTES ?
|
||||
.wc_cbWndExtra NBYTES ?
|
||||
.wc_hInstance HINSTANCE ?
|
||||
.wc_hIcon HICON ?
|
||||
.wc_hCursor HCURSOR ?
|
||||
.wc_hbrBackground HBRUSH ?
|
||||
.wc_lpszMenuName PWCHAR ?
|
||||
.wc_lpszClassName PWCHAR ?
|
||||
.size = $
|
||||
end virtual
|
||||
|
||||
;<EOF>
|
Loading…
Reference in New Issue
Block a user