home *** CD-ROM | disk | FTP | other *** search
/ ticalc.org / ticalc_org_rev_b.iso / archives / 86 / asm / source / cars.asm < prev    next >
Encoding:
Assembly Source File  |  2001-07-01  |  25.3 KB  |  686 lines

  1. ;==================================
  2. ; Cars by Cullen Sauls
  3. ; My first ASM game =)
  4. ; Last Updated: 4-11-99
  5. ; Webpage: http://freeweb.pdq.net/sauls1/
  6. ;    (Visit my webpage to get the most recent version of all my programs!)
  7. ; E-Mail: sauls1@pdq.net
  8. ; ICQ: 11130342
  9. ;
  10. ; IMPORTANT: This game was made by ME! You are allowed to take pieces of it, but you are NOT allowed
  11. ;             to make changes and distribute a modified source. Any and all changes should be for PERSONAL
  12. ;             USE. If you find a better way of doing soemthing, tell me what and I'll try it out and give 
  13. ;             your credit if it works.
  14. ;==================================
  15. ;
  16. #include "asm86.h"                       ;Standard Include Files
  17. #include "ti86asm.inc"                     ;"
  18. ;
  19. .org _asm_exec_ram                       ;Every Program Starts With This
  20. ;
  21. ;--- Commentation For Shell ---;
  22.     nop                                     ;identifier for comment/icon
  23.     jp Start
  24.     .dw 1                                 ;note this is version 1 of the table
  25.                                          ;0 means just a comment
  26.     .dw title                             ;pointer to title
  27.     .dw icon                             ;pointer to icon
  28. ;---
  29. Start:
  30.     call _runindicoff                    ;God I Hate That Thing!
  31.     call _flushallmenus                    ;Close Any Open Windows
  32.     call _clrLCD                        ;Clear The Screen
  33.     ld de,$fc00                            ;Start Drawing At Top-Left Of Screen
  34.     ld hl,TitleScreen                    ;Load The TitleScreen Into HL
  35.     ld bc,496                            ;496 Bytes To Copy
  36.     ldir                                ;Draw The Title Screen
  37.     ld de,$202A                            ;Sets Pen Cursor To (42,32)
  38.     ld (_penCol),de                        ;"
  39.     ld hl,TitleText                        ;Load Title Texts Into HL
  40.     call _vputs                            ;Show Text Menu Style (Small Font)
  41.     ld de,$0005                            ;Set Cursor To (5,0)
  42.     ld (_curRow),de                        ;"
  43.     call _puts                            ;Show Text
  44.     ld de,$3A0C                            ;Sets Pen Cursor To (12,58)
  45.     ld (_penCol),de                        ;"
  46.     call _vputs                            ;Show Text Menu Style (Small Font)
  47.     ld a,5                                ;Load (5,0) Into BC
  48.     ld b,a                                ;"
  49.     xor a                                ;"
  50.     ld c,a                                ;"
  51.     ld de,Car                            ;Load Car Sprite Into DE
  52.     call PutSprite                        ;Show It!
  53.     ld a,5                                ;Load (5,15) Into BC
  54.     ld b,a                                ;"
  55.     ld a,15                                ;"
  56.     ld c,a                                ;"
  57.     ld de,Car                            ;Load Car Sprite Into DE
  58.     call PutSprite                        ;Show It!
  59.     call WaitForEnterOrSecond            ;Call WaitForEnterOrSecond
  60. BeginGame:
  61.     ld hl,0                                ;Set Score To 0
  62.     ld (Score),hl                        ;"
  63.     ld hl,Walls                            ;HL Points To Walla Variables
  64.     ld b,8                                ;The Following Loop Will Repeat 8 Times
  65. SetWallsLoop:
  66.     ld a,5                                ;Sets All Wall Variables To 5
  67.     ld (hl),a                            ;"
  68.     inc hl                                ;"
  69.     djnz SetWallsLoop                    ;"
  70.     ld a,8                                ;A = 8
  71.     ld (CarX),a                            ;Car Starts at 9th Column
  72.     ld hl,SpeedTable                    ;Load SpeedTable Into HL
  73. ;==================================
  74. ; DoMenu Routine By ACZ Coders Electrum and zoomBlock
  75. ;==================================
  76. DoMenu:
  77.     push hl                                ;_clrLCD Destroys HL
  78.  
  79.     call _clrLCD                        ;Clears The Screen
  80.  
  81. ;
  82. ;--- This Was Added By Me To Show The High Score While You Choose Your Speed ---;
  83.     ld hl,$3A29                            ;Set PenCol To (39,55)
  84.     ld (_penCol),hl                        ;"
  85.     ld hl,HiScrStr                        ;Loads The String HiScrStr Into HL
  86.     call _vputs                            ;Show It Menu Style (Small Font)
  87.     ld hl,$3A61                            ;Set PenCol To (97,58)
  88.     ld (_penCol),hl                        ;"
  89.     ld hl,HighScore                        ;Load HighScore Into HL
  90.     call _ldhlind                        ;Still Dunno What This Does
  91.     ld b,5                                ;I Want 5 Didgets With Leading 0's
  92.     call DM_HL_Deci                        ;Show It Menu Style (Small Font)
  93. ;---
  94.     pop hl                                ;Now Restore It
  95.  
  96.     ld c,(hl)                            ;Get Number Of Entries
  97.  
  98.     inc hl                                   ;Move To Menu Title Text
  99.  
  100.     ld de,$0001                            ;Draw At Top, One Char Right
  101.  
  102.     ld    (_penCol),de                    ;Set The Small Font Coords
  103.  
  104.     call _vputs                            ;Print The Title Text
  105.  
  106.     push hl                                ;Save Pointer
  107.  
  108.     ld hl,$fc00                            ;Point To Video Ram
  109.  
  110.     call DoMenuInv                         ;Invert The Top Line
  111.  
  112.     pop hl                                ;Restore Our Pointer
  113.  
  114.     ld b,c                                ;Load Num Entries For Loop
  115.  
  116.     ld de,$0729                            ;Start Printing At Middle Of Second Line
  117.  
  118. DoMenuDTL:
  119.     ld (_penCol),de                        ;Set The Font Coords
  120.  
  121.     call _vputs                            ;Print The Menu Text
  122.  
  123.     ld a,d                                ;Get The Vertical Coord
  124.  
  125.     add a,7                                ;Move To Next Line
  126.  
  127.     ld d,a                                ;Save New Coord
  128.  
  129.     djnz DoMenuDTL                        ;Draw All The Text
  130.  
  131.     ld b,1                                ;Start Menu At First Entry
  132.  
  133.     call DoMenuInvBar                    ;Invert It
  134.  
  135. DoMenuL:
  136.     push bc                                ;Save Entries And Current Entry
  137.  
  138.     call _getky                             ;Read Key Presses
  139.  
  140.     pop bc                                ;Restore It
  141.     cp K_UP                                ;Did They Press Up?
  142.  
  143.     jr z,DoMenuUp                        ;Move Menu Bar Up
  144.  
  145.     cp K_DOWN                            ;Or Was It Down?
  146.  
  147.     jr z,DoMenuDown                        ;Then Move The Bar Down
  148.  
  149.     cp K_SECOND                            ;Did They Hit 2nd?
  150.  
  151.     jr z,DoMenuSelect                    ;Then They Want It
  152.  
  153.     cp K_ENTER                            ;Some People Like Enter
  154.  
  155.     jr z,DoMenuSelect                    ;So Check It Too
  156.  
  157.     jr DoMenuL                            ;They're Just Sitting There, Loop Again
  158.  
  159. DoMenuUp:
  160.     call DoMenuInvBar                    ;Invert Current Selection Back To Normal
  161.  
  162.     dec b                                ;Move Up
  163.  
  164.     jr nz,DoMenuBar                        ;If It's Zero, We're At The Top
  165.  
  166.     ld b,c                                ;So Move To The Bottom
  167.  
  168.     jr DoMenuBar                        ;Handle Menu Bar
  169.  
  170. DoMenuDown:
  171.     call DoMenuInvBar                    ;Same As Up, Go Back To Normal Text
  172.  
  173.     ld a,c                                ;Get Current Entry For Check
  174.  
  175.     cp b                                ;At The Bottom?
  176.  
  177.     jr z,DoMenuDownT                    ;Then Move To The Top
  178.  
  179.     inc b                                ;Move Down
  180.  
  181.     jr DoMenuBar                        ;Handle Menu Bar
  182.  
  183. DoMenuDownT:
  184.     ld b,1                                ;Move To The Top
  185.  
  186. DoMenuBar:
  187.     call DoMenuInvBar                    ;Invert The New Selection
  188.  
  189.     jr DoMenuL                            ;Now It's Time To Loop
  190.  
  191. DoMenuInvBar:
  192.     push bc                                ;Save Position And Entries
  193.  
  194.     ld h,b                                ;Get Position
  195.  
  196.     ld l,112                            ;There Are 7 Lines Of 16 Bytes Each (7*16 = 112)
  197.  
  198.     call _HtimesL                        ;Do The Multiply
  199.  
  200.     ld de,$fc00                            ;We Need To Add To Video Memory
  201.  
  202.     add hl,de                            ;Do The Add
  203.  
  204.     call DoMenuInv                        ;Invert The Line
  205.  
  206.     pop bc                                ;Restore Position And Entries
  207.  
  208.     ret                                    ;Done Inverting
  209.  
  210. DoMenuInv:
  211.     ld b,7*16                            ;Each Row Is 16 Bytes Wide And Text Is 7 Rows High
  212.  
  213. DoMenuIL:
  214.     ld a,(hl)                            ;Get The Byte
  215.  
  216.     cpl                                     ;NOT The Byte--Flips All The Bits
  217.  
  218.     ld (hl),a                            ;Save The New Byte
  219.  
  220.     inc hl                                ;Next Byte
  221.  
  222.     djnz DoMenuIL                        ;Loop For All Bytes
  223.  
  224.     ret                                     ;We're Done With The Invert Loop
  225.  
  226. DoMenuSelect:
  227. ;--- Took Out Unnecessary Stuff (Unnecessary For My Program Exclusively) ---;
  228.     dec b                                ;B = B-1 (Or Speed I Want)
  229.     ld a,4                                ;A = 4
  230.     sub b                                ;A = A-B
  231.     ld (Speed),a                        ;Speed Set Correctly
  232.     ld hl,$fbff                          ;Point To Byte Before The Video Memory
  233.     ld de,$ffff                            ;DE = End Of Video Memory
  234.     ld a,%11111111                       ;Here Is The Line I Want To Draw 
  235. Loop:
  236.     inc hl                                ;HL = HL+1
  237.     ld (hl),a                            ;Draw Line
  238.     call _cphlde                        ;Compare HL And DE
  239.     jr nz,Loop                            ;Routine Will Loop Until HL=DE($ffff)
  240. SetBlankSpots:
  241.     ld hl,$fc05                            ;HL Points To 6th Byte In Video Memory
  242.     xor a                                ;A = 0
  243.     ld de,12                            ;DE = 12
  244.     ld b,64                                ;B = 64 (Want To Draw On All 64 Lines
  245. SBSLoop:
  246.     ld (hl),a                            ;Clear Byte At HL
  247.     inc hl                                ;HL = HL+1
  248.     ld (hl),a                            ;Clear Byte At HL
  249.     inc hl                                ;HL = HL+1
  250.     ld (hl),a                            ;Clear Byte At HL
  251.     inc hl                                ;HL = HL+1
  252.     ld (hl),a                            ;Clear Byte At HL (Repetative, Ain't It =)
  253.     inc hl                                ;HL = HL+1
  254.     ld (hl),a                            ;Clear Byte At HL
  255.     add hl,de                            ;HL = HL+DE
  256.     djnz SBSLoop                        ;B = B-1; If B != 0, Go To SBSLoop
  257. GameStart:
  258.     ld a,7                                ;A = 7
  259.     ld b,a                                ;B = A
  260.     ld a,(CarX)                            ;A = CarX
  261.     ld c,a                                ;C = A
  262.     ld de,Car                            ;Load Car Sprite Into DE
  263.     call PutSprite                        ;Show It!
  264.     call _getky                            ;Read Key Presses
  265.     cp K_EXIT                            ;Was Exit Pressed?
  266.     jp z,End                            ;If So, Go To End
  267.     cp K_MORE                            ;Was More Pressed?
  268.     call z,Pause                        ;If So, Call Pause
  269.     cp K_RIGHT                            ;Was Right Arrow Pressed?
  270.     call z,MoveRight                    ;If So, Call MoveRight
  271.     cp K_LEFT                            ;Was Left Arrow Pressed?
  272.     call z,MoveLeft                        ;If So, Call MoveLeft
  273.     cp K_DEL                            ;Was Delete Pressed
  274.     jp z,BeginGame                        ;If So, Let Them Start Over (Go To BeginGame)
  275. DrawRoads:
  276.     ld hl,Walls+7                        ;Point To Last Wall Variable
  277.     ld b,8                                ;Want To Draw On All 8 Rows
  278. DRLoop:
  279.     dec b                                ;B = B-1
  280.     ld a,(hl)                            ;Get Where The Wall Is
  281.     ld c,a                                ;C = A
  282.     ld de,Side                            ;Want To Draw The Side Sprite
  283.     push bc                                ;Save B Cause PutSprite Destroys It
  284.     push af                                ;Save A Cause PutSprite Destroys It
  285.     push hl                                ;Save HL
  286.     call PutSprite                        ;Draw The Sprite
  287.     pop hl                                ;Save HL
  288.     pop af                                ;Restore A
  289.     pop bc                                ;Restore B
  290.     ld a,(hl)                            ;Get Where The Wall Is
  291.     inc a                                ;A = A+1
  292.     ld c,a                                ;C = A
  293.     ld de,Road                            ;Want To Draw The Road Sprite
  294.     push bc                                ;Save B
  295.     push af                                ;Save A
  296.     push hl                                ;Save HL
  297.     call PutSprite                        ;Draw The Sprite
  298.     pop hl                                ;Save HL
  299.     pop af                                ;Restore A
  300.     pop bc                                ;Restore C
  301.     ld a,(hl)                            ;Get Where The Wall Is
  302.     add a,5                                ;A = A+5
  303.     ld c,a                                ;C = A
  304.     ld de,Road                            ;Want To Draw The Road Sprite
  305.     push bc                                ;Save B
  306.     push af                                ;Save A
  307.     push hl                                ;Save HL
  308.     call PutSprite                        ;Draw The Sprite
  309.     pop hl                                ;Restore HL
  310.     pop af                                ;Restore A
  311.     pop bc                                ;Restore B
  312.     ld a,(hl)                            ;Get Where The Wall Is
  313.     add a,6                                ;A = A+6
  314.     ld c,a                                ;C = A
  315.     ld de,Side                            ;Want To Draw The Side Sprite
  316.     push bc                                ;Save B
  317.     push af                                ;Save A
  318.     push hl                                ;Save HL
  319.     call PutSprite                        ;Draw The Sprite
  320.     pop hl                                ;Restore HL
  321.     pop af                                ;Restore A
  322.     pop bc                                ;Restore B
  323.     dec hl                                ;HL = HL-1; The Next Side To Draw (1 Row Down)
  324.     inc b                                ;B = B+1
  325.     djnz DRLoop                             ;B = B-1; If B=0, Conctinue, Otherwise, Go To DrawRoads
  326. ;
  327. ;--- Shows Your Score In Upper Left ---;
  328.     ld hl,$0000                            ;Set PenCol To Upper Left
  329.     ld (_penCol),hl                        ;"
  330.     ld hl,Score                            ;HL = Score
  331.     call _ldhlind                        ;HL = (HL); HL = Number At Address HL
  332.     ld b,5                                ;Want It To Print 5 Didgets With Leading 0's
  333.     call DM_HL_Deci                        ;Show It Menu Style (Small Font)
  334. ;---
  335.     ld a,7                                ;A = 7
  336.     ld b,a                                ;B = A
  337.     ld a,(CarX)                            ;A = CarX
  338.     ld c,a                                ;C = A
  339.     ld de,Car                            ;Load Car Sprite Into DE
  340.     call PutSprite                        ;Show It!
  341. AreYouDead:
  342.     ld a,(CarX)                            ;A = CarX
  343.     ld b,a                                ;B = A
  344.     ld a,(Walls+7)                        ;A = 8th Wall Variable
  345.     cp b                                ;See If You Hit Left Side
  346.     jp z,IsDead                            ;If So, You Are Dead =(
  347.     add a,6                                ;A = A+6
  348.     cp b                                ;See If You Hit Right Side
  349.     jp z,IsDead                            ;If So, You Are Dead =(
  350. ;
  351. ;--- Increases Score ---;
  352.     ld hl,(Score)                        ;HL = Score
  353.     inc hl                                ;HL = HL+1
  354.     ld (Score),hl                        ;New Score Is Saved
  355. ;---
  356.     call Scroll                            ;Call Scroll Routine
  357.     call SpeedOfGame                    ;Call SpeedOfGame Routine (Slow Game Accorddingly)
  358.     jp GameStart                        ;Go Back To GameStart And Begin Loop Again
  359. ;==================================
  360. ; Subroutines
  361. ;==================================
  362. SpeedOfGame:
  363.     ld a,(Speed)                        ;A = Speed
  364.     or a                                ;Is A 0?
  365.     ret z                                ;Return If So
  366.     ld b,a                                ;B = A
  367. SpeedLoop:
  368.     halt                                ;Slow Game
  369.     djnz SpeedLoop                        ;Go To SpeedLoop If B != 0
  370.     ret                                 ;Return To Game
  371. IsDead:
  372.     call _clrLCD                        ;Clear The Screen
  373.     ld hl,$0000                            ;Set Cursor Coords To (0,0)
  374.     ld (_curRow),hl                        ;"
  375.     ld hl,YouDied                        ;Load The String YouDied Into HL
  376.     call _puts                            ;Show It!
  377.     ld hl,$151F                            ;Sets PenCol To (31,21)
  378.     ld (_penCol),hl                        ;"
  379.     ld hl,FinalScore                    ;Load String FinalScore Into HL
  380.     call _vputs                            ;Display It Menu Style (Small Font)
  381.     ld hl,$154D                            ;Set PenCol To (77,21)
  382.     ld (_penCol),hl                        ;"
  383.     ld hl,Score                            ;Load Your Score Into HL
  384.     call _ldhlind                        ;HL = (HL); HL = Number At Address HL
  385.     ld b,5                                ;Want To Show 5 Didgets With Leading 0's
  386.     call DM_HL_Deci                        ;Show It Menu Style (Small Font)
  387.     ld hl,$0004                            ;Set The Cursor Coords To (4,0)
  388.     ld (_curRow),hl                        ;"
  389.     ld hl,PlayAgain                        ;Load The String PlayAgain Into HL
  390.     call _puts                            ;Show It!
  391.     ld hl,(HighScore)                    ;Load The Current High Score Into HL
  392.     ld de,(Score)                        ;DE = Score
  393.     call _cphlde                        ;Compare HL And DE
  394.     jr nc,NotHighScore                    ;If Your Score Is Not Higher, Go To NotHighScore
  395. NewHighScore:
  396.     ld hl,$0000                            ;Set Cursor To (0,0)
  397.     ld (_curRow),hl                        ;"
  398.     ld hl,NewHigh                        ;Load The String NewHigh Into HL
  399.     call _puts                            ;Show It!
  400.     call InvTopRows                        ;Invert Top 2 Large Font Lines
  401.     ld hl,(Score)                        ;HL = Score
  402.     ld (HighScore),hl                    ;HighScore = HL
  403.     call SaveHigh                        ;Save It!
  404. NotHighScore:
  405. WaitForAnswer:
  406.     call _getkey                        ;Wait For A Key To Be Pressed
  407.     cp kF1                                ;Was F1 Pressed?
  408.     jp z,BeginGame                        ;If So, Play Game Again
  409.     cp kF2                                ;Was F2 Pressed?
  410.     jr z,End                            ;If So, Quit Game
  411.     jr WaitForAnswer                    ;If Neither 1 Or 2 Was Pressed, Go To WaitForAnswer
  412. WaitForEnterOrSecond:
  413.     call _getky                            ;Wait For A Key TO Be Pressed
  414.     cp K_ENTER                            ;Was Enter Pressed?
  415.     ret z                                ;If So, Return To Game
  416.     cp K_SECOND                            ;Was 2nd Pressed?
  417.     ret z                                ;If So, Return To Game
  418.     jr WaitForEnterOrSecond                ;If Neither Were Pressed, Go To WaitForEnterOrSecond
  419. End:
  420. static_on:                                ;Static Routine By Macross Software
  421.     ld b, 255                            ;I Have No Idea How It Works Right Now =P
  422. ClearSplit:                                ;"
  423.     push bc                                ;"
  424.     LD a, r                                ;"
  425.     LD h, a                                ;"
  426.     LD a, r                                ;"
  427.     LD l, a                                ;"
  428.     LD de,$fc00                            ;"
  429.     LD bc,1024                            ;"
  430.     ldir                                ;"
  431.     pop bc                                ;"
  432.     djnz ClearSplit                        ;"
  433.     call _clrLCD                        ;Clear The LCD
  434.     ld hl,$0000                            ;Set Cursor Coords To (0,0)
  435.     ld (_curRow),hl                        ;"
  436.     ld hl,Programmed                    ;Load The String Programmed Into HL
  437.     call _puts                            ;Show It!
  438.     call InvTopRows                        ;Call InvTopRows Routine
  439.     call _getkey                        ;Wait For Any Key To Be Pressed    
  440.     call _clrLCD                        ;Clears The Screen
  441.     ret                                    ;Quit Program, Return To Shell/Normal OS
  442. Pause:
  443.     ld hl,$0000                            ;Set Cursor Coords To (0,0)
  444.     ld (_curRow),hl                        ;"
  445.     ld hl,Paused                        ;Load The String Paused Into HL
  446.     call _puts                            ;Show It!
  447. PauseForMore:
  448.     call _getky                            ;Reads Key Presses
  449.     cp K_MORE                            ;Was More Pressed?
  450.     jr nz,PauseForMore                    ;If It Wasn't, Go To PauseForMore
  451.     ld hl,$fc00                            ;HL Points To Video Memory
  452.     ld a,%11111111                        ;Line To Draw
  453.     ld b,128                            ;Loop Will Repeat 128 Times
  454. PFMLoop:
  455.     ld (hl),a                            ;Draw A To Address HL Points To
  456.     inc hl                                ;HL = HL+1
  457.     djnz PFMLoop                        ;B = B-1; If B != 0, Go To PFMLoop
  458.     ret                                    ;Return To Game
  459. MoveRight:
  460.     ld a,(CarX)                            ;A = CarX
  461.     cp 15                                ;Is The Car At Far-Right Already?
  462.     jp z,GameStart                        ;If So, Return To Game
  463.     ld a,7                                ;A = 7
  464.     ld b,a                                ;B = A
  465.     ld a,(CarX)                            ;A = CarX
  466.     ld c,a                                ;C = A
  467.     ld de,Road                            ;Load Car Sprite Into DE
  468.     call PutSprite                        ;Show It!
  469.     ld a,(CarX)
  470.     inc a                                ;A = A+1
  471.     ld (CarX),a                            ;CarX = A
  472.     ret                                    ;Return To Game
  473. MoveLeft:
  474.     ld a,(CarX)                            ;A = CarX
  475.     or a                                ;Is The Car At Far-Left Already?
  476.     jp z,GameStart                        ;If So, Return To Game
  477.     ld a,7                                ;A = 7
  478.     ld b,a                                ;B = A
  479.     ld a,(CarX)                            ;A = CarX
  480.     ld c,a                                ;C = A
  481.     ld de,Road                            ;Load Car Sprite Into DE
  482.     call PutSprite                        ;Show It!
  483.     ld a,(CarX)
  484.     dec a                                ;A = A-1
  485.     ld (CarX),a                            ;CarX = A
  486.     ret                                    ;Return To Game
  487. Scroll:
  488.     ld a,(Walls+6)                        ;Scrolls Road
  489.     ld (Walls+7),a                        ;"
  490.     ld a,(Walls+5)                        ;"
  491.     ld (Walls+6),a                        ;"
  492.     ld a,(Walls+4)                        ;"
  493.     ld (Walls+5),a                        ;"
  494.     ld a,(Walls+3)                        ;"
  495.     ld (Walls+4),a                        ;"
  496.     ld a,(Walls+2)                        ;"
  497.     ld (Walls+3),a                        ;"
  498.     ld a,(Walls+1)                        ;"
  499.     ld (Walls+2),a                        ;"
  500.     ld a,(Walls)                        ;"
  501.     ld (Walls+1),a                        ;"
  502. GetRand:
  503.     ld a,0                                ;Low Bound Of Random Number
  504.     call _SetXXOP1                        ;OP1 = A
  505.     ld a,7                                ;High Bound Of Random Number
  506.     call _SetXXOP2                        ;OP2 = A
  507.     call _randint                        ;Gets A Rondom Integer Between OP1 And OP2 (0 And 7 In This Case)
  508.     call _convop1                        ;A = Random Number
  509.     cp 1                                ;Was The Random Number 1?
  510.     jr z,Left                            ;If So, Go To Left
  511.     cp 2                                ;Was The Random Number 2?
  512.     jr z,Left                            ;If So, Go To Left
  513.     cp 3                                ;Was The Random Number 3?
  514.     jr z,Left                            ;If So, Go To Left
  515.     cp 4                                ;Was The Random Number 4?
  516.     jr z,Right                            ;If So, Go To Right
  517.     cp 5                                ;Was The Random Number 5?
  518.     jr z,Right                            ;If So, Go To Right
  519.     cp 6                                ;Was The Random Number 6?
  520.     jr z,Right                            ;If So, Go To Right
  521.     ret nz                                ;If None Of The Above, Road Continues Straight
  522. Left:
  523.     ld a,(Walls)                        ;A = Walls
  524.     or a                                ;Is Road Already At Far-Left?
  525.     ret z                                ;If So, Return To Game
  526.     dec a                                ;A = A-1
  527.     ld (Walls),a                        ;Walls = A
  528.     ret                                    ;Return To Game
  529. Right:
  530.     ld a,(Walls)                        ;A = Walls
  531.     cp 9                                ;Is Road Already At Far-Right?
  532.     ret z                                ;If So, Return To Game
  533.     inc a                                ;A = A+1
  534.     ld (Walls),a                        ;Walls = A
  535.     ret                                    ;Return To Game
  536. DM_HL_Deci:
  537.     ld de,String+5                        ;Need 6 Bytes
  538.     xor a                                ;A = 0
  539.     ld (de),a                            ;Address That DE Points To = 0
  540. RepUnp:
  541.     dec de                                ;DE = DE-1
  542.     call _divHLby10                        ;HL = HL/10; A = Remainder
  543.     add a,48                            ;A = A+48 ('0' = 48)
  544.     ld (de),a                            ;Address That DE Points To = A
  545.     djnz RepUnp                            ;B = B-1; If B != 0, Go To RepUnp
  546.     ex de,hl                            ;HL = DE; DE = HL
  547.     jp _vputs                            ;Display The Number
  548. InvTopRows:
  549.     ld hl,$fc00                            ;HL Points To Video Memory
  550.     ld a,%11111111                        ;Line To Draw
  551.     ld (hl),a                            ;Address That HL Points To = A
  552.     inc hl                                ;HL = HL+1
  553.     ld b,255                            ;B = 255
  554. ITRLoop:
  555.     ld a,(hl)                            ;A = What's At HL's Address
  556.     cpl                                    ;Invert The Pixels
  557.     ld (hl),a                            ;What's At HL's Address = A
  558.     inc hl                                ;HL = HL+1
  559.     djnz ITRLoop                        ;B = B-1; If B != 0, Go To ITRLoop
  560.     ret                                    ;Return To Where Routine Was Called
  561. ;
  562. ;--- SaveHigh Was Taken From ZTetris Also, But Slightly Modified ---;
  563. SaveHigh:                                ;Saves The New High Score
  564.     ld hl,ProgName                        ;All This Stuff Is To Make Sure The Hiscore Table
  565.     rst 20h                                ;And Resume Stuff Are Stored In The Variable
  566.     rst 10h                                ;Dunno What This Does---I Didn't Write Routine =)
  567.     ex de,hl                            ;HL -> Start Of Variable
  568.     ld a,b                                ;A = B
  569.     ld de,HighScore-$D748+4                ;DE = Relative Offset To Stuff To Store (-4)
  570.     add hl,de                            ;HL = HL+DE
  571.     adc a,0                                ;Next Block If Necessary
  572.     ld de,HighScore                           ;DE = Start Of Bytes To Copy
  573.     ld b,2                                   ;2 Bytes To Copy
  574. RepCopy:
  575.     push af                                ;Save AF
  576.     push hl                                ;Save HL
  577.     call $46C3                            ;Call Whatever Is At $46C3
  578.     ld a,(de)                            ;Read
  579.     ld (hl),a                            ;And Save It In The Real Variable
  580.     pop hl                                ;Restore HL
  581.     pop af                                ;Restore AF
  582.     call $4637                            ;Call Whatever Is At $4637
  583.     inc de                                ;DE = DE+1
  584.     djnz RepCopy                        ;B = B-1; If B != 0, Go To RepCopy
  585.     ret                                    ;Return To Calling Routine
  586. ;==================================
  587. ; Put Sprite
  588. ;==================================
  589. PutSprite:
  590.      push de                             ;** We Need To Save DE
  591.      ld hl,$fb80                         ;Point To The First Byte In Video Memory - 128 Bytes
  592.      inc b                               ;B=B+1
  593.      ld de,$80                           ;Number Of Bytes Per Line
  594. YCoord:
  595.      add hl,de                            ;HL = HL+DE
  596.      djnz YCoord                        ;B=B-1; If B != 0, Go To YCoord
  597.      add hl,bc                               ;Now HL Points To VID_MEM + OFFSET
  598.      pop de                                  ;** Now DE Still Points To Pprite
  599.      ld b,8                                ; Repeat 8 Times
  600. CopySprite:
  601.      push bc                                 ;Save The Counter
  602.      ld a,(de)                               ;Get One Byte Of Sprite
  603.      ld (hl),a                               ;Copy It To Video Mem
  604.      inc de                                 ;Point To Next Byte Of Sprite
  605.      ld bc,16                                ;"
  606.      add hl,bc                           ;Offset Vid Mem By 16 Bytes (Go Next Line Down)
  607.      pop bc                              ;Get The Counter Back
  608.      djnz CopySprite                      ;Do The Loop
  609.      ret                                 ;End Of The Routine
  610. ;==================================
  611. ; Strings
  612. ;==================================
  613. TitleText:
  614.     .db "Version    1.6",0
  615.     .db "   By Cullen Sauls   "
  616.     .db "   sauls1@pdq.net",0
  617.     .db "http://freeweb.pdq.net/sauls1",0
  618. Paused:
  619.     .db "Paused               ",0
  620. NewHigh:
  621.     .db "  Congratulations!!  "
  622.     .db "  A New High Score!  ",0
  623. YouDied:
  624.     .db "     You Crashed",0
  625. FinalScore:
  626.     .db "Final Score:",0
  627. PlayAgain:
  628.     .db "     Play Again?     "
  629.     .db "       F1: Yes       "
  630.     .db "       F2: No",0
  631. Programmed:
  632.     .db "    Programmed by    "
  633.     .db "    Cullen  Sauls",0
  634. HiScrStr:
  635.     .db "High Score:",0
  636. ;==================================
  637. ; Variables
  638. ;==================================
  639. Walls:
  640.  .db 5,5,5,5,5,5,5,5                            ;8 Bytes, For All 8 Rows Of Screen
  641. String                        =         $C126        ;6 Bytes
  642. CarX:                        .db        8            ;1 Byte
  643. Speed:                        .db        0            ;1 Byte
  644. Score:                        .dw        0            ;Word (2 Bytes)
  645. HighScore:                    .dw        0            ;Word (2 Bytes)
  646. ProgName:                    .db     $12,4,"Cars"
  647. ;==================================
  648. ; Data For Shell Comments
  649. ;==================================
  650. title:
  651.     .db "CARS version 1.6 by Cullen Sauls",0
  652. icon:
  653.     .db 8,1                    ;this is the height, then the width (in bytes)
  654.     .db %00011000            ;then a bitmap
  655.     .db %01011010            ;as with comments, this can be placed anywhere
  656.     .db %01111110
  657.     .db %01011010
  658.     .db %00011000
  659.     .db %11011011
  660.     .db %11111111
  661.     .db %11000011
  662. ;==================================
  663. ; Table Data  {had to change the string commands to .db (were .dw)}
  664. ;==================================
  665. SpeedTable:
  666.   .db 5                                  ;num entries
  667.  
  668.   .db "Choose Your Speed:",0            ;title text (at the top)
  669.  
  670.   .db "Wheres the gas?",0                  ;text for each entry
  671.  
  672.   .db "Driving Miss Daisey",0            ;"
  673.   .db "Freeway",0                        ;"
  674.   .db "Driving Over Miss Daisey",0        ;"
  675.   .db "Wheres the brake?!",0            ;"
  676. ;==================================
  677. ; Title Screen Data
  678. ;==================================
  679. TitleScreen:
  680.  .db 0,0,0,%11,%11111111,%11111111,%11111111,%11111111,%11111111,%11111111,%11111111,%11111111,%11100000,0,0,0
  681.  .db 0,0,0,%11,%11111111,%11111111,%11111111,%11111111,%11111111,%11111111,%11111111,%11111111,%11100000,0,0,0
  682.  .db 0,0,0,%11,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%01100000,0,0,0
  683.  .db 0,0,0,%11,%00001111,%11111111,%00001111,%11111000,%01111111,%11111000,%00001111,%11111111,%01100000,0,0,0
  684.  .db 0,0,0,%11,%00011111,%11111111,%00011111,%11111100,%01111111,%11111100,%00011111,%11111111,%01100000,0,0,0
  685.  .db 0,0,0,%11,%00111111,%11111111,%00111111,%11111110,%01111111,%11111110,%00111111,%11111111,%01100000,0,0,0
  686.  .db 0,0,0,%11,%01111111,%11111111,%01111111,%11111111,%01111111,%11111111,%01111111,%11111111,%01100000,0,0,0
  687.  .db 0,0,0,%11,%01111111,%11111111,%01111111,%11111111,%01111111,%11111111,%01111111,%11111111,%01100000,0,0,0
  688.  .db 0,0,0,%11,%00000000,%00000000,%00000000,%00011111,%00000000,%00011111,%00000000,%00000000,%01100000,0,0,0
  689.  .db 0,0,0,%11,%00000000,%00000000,%00000000,%00011111,%00000000,%00011111,%00000000,%00000000,%01100000,0,0,0
  690.  .db 0,0,0,%11,%00000000,%00000000,%00000000,%00011111,%00000000,%00011111,%00000000,%00000000,%01100000,0,0,0
  691.  .db 0,0,0,%11,%01111100,%00000000,%01111100,%00011111,%01111100,%00011111,%01111100,%00000000,%01100000,0,0,0
  692.  .db 0,0,0,%11,%01111100,%00000000,%01111100,%00011111,%01111100,%00011111,%01111100,%00000000,%01100000,0,0,0
  693.  .db 0,0,0,%11,%01111100,%00000000,%01111111,%11111111,%01111111,%11111110,%01111111,%11111000,%01100000,0,0,0
  694.  .db 0,0,0,%11,%01111100,%00000000,%01111111,%11111111,%01111111,%11111100,%01111111,%11111100,%01100000,0,0,0
  695.  .db 0,0,0,%11,%01111100,%00000000,%01111111,%11111111,%01111111,%11111000,%00111111,%11111110,%01100000,0,0,0
  696.  .db 0,0,0,%11,%01111100,%00000000,%01111111,%11111111,%01111111,%11111100,%00011111,%11111111,%01100000,0,0,0
  697.  .db 0,0,0,%11,%01111100,%00000000,%01111111,%11111111,%01111111,%11111110,%00001111,%11111111,%01100000,0,0,0
  698.  .db 0,0,0,%11,%01111100,%00000000,%01111100,%00011111,%01111100,%00011111,%00000000,%00011111,%01100000,0,0,0
  699.  .db 0,0,0,%11,%01111100,%00000000,%01111100,%00011111,%01111100,%00011111,%00000000,%00011111,%01100000,0,0,0
  700.  .db 0,0,0,%11,%01111100,%00000000,%01111100,%00011111,%01111100,%00011111,%00000000,%00011111,%01100000,0,0,0
  701.  .db 0,0,0,%11,%01111100,%00000000,%01111100,%00011111,%01111100,%00011111,%00000000,%00011111,%01100000,0,0,0
  702.  .db 0,0,0,%11,%01111100,%00000000,%01111100,%00011111,%01111100,%00011111,%00000000,%00011111,%01100000,0,0,0
  703.  .db 0,0,0,%11,%01111111,%11111111,%01111100,%00011111,%01111100,%00011111,%01111111,%11111111,%01100000,0,0,0
  704.  .db 0,0,0,%11,%01111111,%11111111,%01111100,%00011111,%01111100,%00011111,%01111111,%11111111,%01100000,0,0,0
  705.  .db 0,0,0,%11,%00111111,%11111111,%01111100,%00011111,%01111100,%00011111,%01111111,%11111110,%01100000,0,0,0
  706.  .db 0,0,0,%11,%00011111,%11111111,%01111100,%00011111,%01111100,%00011111,%01111111,%11111100,%01100000,0,0,0
  707.  .db 0,0,0,%11,%00001111,%11111111,%01111100,%00011111,%01111100,%00011111,%01111111,%11111000,%01100000,0,0,0
  708.  .db 0,0,0,%11,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%01100000,0,0,0
  709.  .db 0,0,0,%11,%11111111,%11111111,%11111111,%11111111,%11111111,%11111111,%11111111,%11111111,%11100000,0,0,0
  710.  .db 0,0,0,%11,%11111111,%11111111,%11111111,%11111111,%11111111,%11111111,%11111111,%11111111,%11100000,0,0,0
  711. ;==================================
  712. ; Sprites
  713. ;==================================
  714. Road:
  715.     .db %00000000
  716.     .db %00000000
  717.     .db %00000000
  718.     .db %00000000
  719.     .db %00000000
  720.     .db %00000000
  721.     .db %00000000
  722.     .db %00000000
  723. Side:
  724.     .db %11111111
  725.     .db %11111111
  726.     .db %11111111
  727.     .db %11111111
  728.     .db %11111111
  729.     .db %11111111
  730.     .db %11111111
  731.     .db %11111111
  732. Car:
  733.     .db %00011000
  734.     .db %01011010
  735.     .db %01111110
  736.     .db %01011010
  737.     .db %00011000
  738.     .db %11011011
  739.     .db %11111111
  740.     .db %11000011
  741. ;
  742. .message Copyright ⌐ 1999 Cullen Sauls
  743. ;
  744. .end
  745.  
  746. ;********** THAT'S IT!!!!! **********;
  747.  
  748. ;Special Thanks:
  749. ;Matt Johnson for his 86 ASM tutorials.
  750. ;Trent Lillehaugen for his Frogger tutorial.
  751. ;And anyone else who helped me with my questions.
  752.