; ; TRON 1.1 - By: Scoobie <_scoobie@geocities.com> ; This game was made by request because it's easy. ; Yes, this IS Pong minus a few things. =) ; *NO* OShell conversions shall be posted without my permission. ; Final Note: This program would make any decent ASM programmer puke. =) ; ; I would like to play it so I adapted it to CrASH. Eric Piel (June 98) #INCLUDE "CRASH82.INC" BUSY_OFF =$3932-$1A ; turn off "busy" indicator .db "Tron 1.1",0 ;*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*- ; Memory Allocations ;*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*- Player1_x = TEXT_MEM ; Player 1's x Position Player1_y = TEXT_MEM + 1 ; Player 1's y Position Player1_Dir = TEXT_MEM + 2 ; Player 1's Direction Player2_x = TEXT_MEM + 3 ; Player 2's x Position Player2_y = TEXT_MEM + 4 ; Player 2's y Position Player2_Dir = TEXT_MEM + 5 ; Player 2's Direction Game_Speed = TEXT_MEM + 6 ; How fast ya' wanna' go? Player1_Sc = TEXT_MEM + 7 ; Player 1's score Player2_Sc = TEXT_MEM + 9 ; Player 2's score Points = TEXT_MEM + 11 ; Points in a game ;*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*- ; Initializations ;*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*- ROM_CALL(BUSY_OFF) ; Turn off the busy indicator LD A,$8C ; set to ROM page 4 for graphics OUT (2),A call CR_GRBCopy ;Fast clear ;ROM_CALL(CLEARLCD) set 3,(IY+05) ;set text to White on Black SET 1,(IY+$05) ;Display the entire 7 rows of the character RES 1,(IY+$0D) ;Don't alter text memory with writes ld hl,0320h ;ld A, 20 ld (CURSOR_X),hl ;ld (CURSOR_Y), A ;ld A, 18 ;ld (CURSOR_X), A ld HL,msgTitle ROM_CALL(D_ZM_STR) ld hl,1A1Bh ;\Display Game Speed Message ld (CURSOR_X),hl ld HL,msgSpeed ROM_CALL(D_ZM_STR) res 3,(IY+$05) ;reset text to Black on White res 1,(IY+$05) ;Display only 6 rows of the character ld hl,0B0Fh ld (CURSOR_X),hl ld HL, msgAuthor ROM_CALL(D_ZM_STR) ld hl,300Fh ld (CURSOR_X),hl ld HL, msgSiteName ROM_CALL(D_ZM_STR) ld hl,3803h ld (CURSOR_X),hl ld HL, msgWebSite ROM_CALL(D_ZM_STR) Speed: ld hl,2210h ld (CURSOR_X),hl ld HL, SzArrow ROM_CALL(D_ZM_STR) ld A, 13 ld (Game_Speed), A Update_Speed: ld hl,221Dh ld (CURSOR_X),hl ld A, (Game_Speed) cp 3 jr z, TooFast cp 8 jr z, Fast cp 13 jr z, Normal cp 18 jr z, Slow TooSlow: ld HL,msgTooSlow jr Finish_Update_Speed TooFast: ld HL,msgTooFast jr Finish_Update_Speed Fast: ld HL,msgFast jr Finish_Update_Speed Normal: ld HL,msgNormal jr Finish_Update_Speed Slow: ld HL,msgSlow Finish_Update_Speed: ROM_CALL(D_ZM_STR) Options_Test: call GET_KEY cp G_MODE ret z cp G_ENTER jr z,Initialize cp $02 jr z,Slower cp $03 jr nz,Options_Test Faster: ld A,(Game_Speed) cp 3 jr z,Options_Test sub 5 jr No_Change Slower: ld A,(Game_Speed) cp 23 jr z,Options_Test add A, 5 No_Change: ld (Game_Speed), A jr Update_Speed Initialize: ROM_CALL(CLEARLCD) ld B, 94 Border_Top: ld C, 0 CALL Point_On ld C, 63 CALL Point_On djnz Border_Top ld B, 62 Border_Sides: ld c,b push BC ld B, 0 CALL Point_On ld B, 95 CALL Point_On pop BC djnz Border_Sides ; set starting positions ld hl,0F2Fh ld (Player1_x),hl ld hl,2F03h ld (Player1_Dir),hl ld hl,0130h ld (Player2_y),hl ld hl,0 ld (Points),hl jr Draw ;*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*- ; TRON ;*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*- Begin: Continue: ld hl,(Points) inc hl ld (Points),hl ld A, (Game_Speed) ; See how simple it is to slow the game down? =) ld B, A Delay: HALT djnz Delay jr KeyPress ; Test for key presses *Side Note: If the ; game can end in a subroutine, such as ; KeyPress and TestBall, use jumps instead ; of CALLs so there's no mess left over. ; (i.e. If you CALLed the sub., then the ; QUIT sub.'s RET would return to the ; origin of the CALL and not kill the ; program.) Draw: ld hl,Player1_Dir call Draw_P ld hl,Player2_Dir call Draw_P jr Begin ;*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*- ;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> KeyPress: xor a ;ld A, 0 ; reset keys out (1), A ; get keys in A, (1) ; get keys ;cpl ; I want the opposite of the key value (Aren't I fussy?) =) xor 255 ; no keys pressed? jr z,Test_Collision ; nope. back to game. push AF bit 6, A ; [MODE],[CLEAR],[VARS],[PRGM],[MATRIX],[MATH] pressed? jp nz,Pop_Quit ; Get The Hell Out Of Here! pop AF ld hl,Player1_Dir push AF bit 1, A ;[<],[STO],[1],[2],[3],[+],[TRACE] pressed? call nz,P_Left ;The bit tested was a one, sooo... pop AF push AF bit 2, A ;[>],[LN],[4],[5],[6],[-],[ZOOM] pressed? call nz,P_Right ;The bit tested was a one, sooo... pop AF ld hl,Player2_Dir push AF bit 3, A ;[^],[LOG],[7],[8],[9],[*],[WINDOW] pressed? call nz,P_Left ;The bit tested was a one, sooo... pop AF ;push AF bit 0, A ;[V],[x2],[,],[(],[)],[/],[Y=] pressed? call nz,P_Right ;The bit tested was a one, sooo... ;pop AF ;jp Test_Collision ; Test if either player has collided ;(((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((( Test_Collision: ld hl,(Player1_x) ld B, l ld C, h ld A, (Player1_Dir) cp 1 jr z, Sub1_y cp 2 jr z, Sub1_x cp 3 jr z, Inc1_y Inc1_x: inc B jr Test1 Inc1_y: inc C jr Test1 Sub1_y: dec C jr Test1 Sub1_x: dec B Test1: CALL GetPixel or A ld D, 0 jr z, Test_P2 ; D = 0 - P1 didn't contact something ld D, 1 ; D = 1 - P1 hit something Test_P2: ld hl,(Player2_x) ld B, l ld C, h ld A, (Player2_Dir) cp 1 jr z, Sub2_y cp 2 jr z, Sub2_x cp 3 jr z, Inc2_y Inc2_x: inc B jr Test2 Inc2_y: inc C jr Test2 Sub2_y: dec C jr Test2 Sub2_x: dec B Test2: CALL GetPixel or A jr z,Test_1 ; P2 didn't contact anything ;Test_Tie: ; P2 did contact something ld hl,Player2_Sc ld A, D or A jr z,P_Wins ; P1 didn't jr Tie ; P1 did too Test_1: ; P2 didn't contact anything ld hl,Player1_Sc ld A, D or A jp z,Draw ; neither did P1 ;jp P_Wins ; P1 did contact something ;)()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()( P_Wins: push af ; ld de,(Points) ;add points to the P who won ; ld c,(hl) ; inc hl ; ld b,(hl) ; ex de,hl ; add hl,bc ; ex de,hl ; ld (hl),d ; dec hl ; ld (hl),e ld bc,(Points) ;add Points to the P who won ld a,c add a,(hl) ld (hl),a ld a,b inc hl adc a,(hl) ld (hl),a ; ld de,(Points) ; push hl ; ld hl,(hl) ; add hl,de ; ex de,hl ; pop hl ; ld (hl),e ; inc hl ; ld (hl),d ROM_CALL(CLEARLCD) ld hl,1004h ld (CURSOR_X),hl ld HL, msgP1Wins ROM_CALL(D_ZM_STR) pop af jr nz,Keep_Playing ld hl,1051h ld (CURSOR_X),hl ld a,'2' ROM_CALL(M_CHARPUT) jr Keep_Playing Tie: ROM_CALL(CLEARLCD) ld hl,1020h ld (CURSOR_X),hl ld HL,msgTie ROM_CALL(D_ZM_STR) Keep_Playing: ld hl,3235h ld (CURSOR_X),hl ld HL, msgQuit ROM_CALL(D_ZM_STR) ld hl,0000h ;score ld (CURSOR_POS),hl ld hl,(Player1_Sc) ROM_CALL(D_HL_DECI) ld a,09h ld (CURSOR_COL),a ld hl,(Player2_Sc) ROM_CALL(D_HL_DECI) ; ld a,(Player1_Sc+1) ; cp 2 ;did P1 win? ; jr nc,Fin ; ld a,(Player2_Sc+1) ; cp 2 ; jr c,NextP ld hl,(Player2_Sc) ld de,500 call CP_HL_DE ;hl contains P2sc jr nc,Fin ld hl,(Player1_Sc) call CP_HL_DE jr c,NextP Fin: ld hl,1C11h ld (CURSOR_X),hl ld HL,msgWon ROM_CALL(D_ZM_STR) KeyFin: call CR_KHAND cp K_MODE ret z jr KeyFin NextP: ld hl,2806h ld (CURSOR_X),hl ld HL,msgPressEnter ROM_CALL(D_ZM_STR) Another_Loop: call CR_KHAND cp K_MODE ret z cp K_ENTER jp z,Initialize jr Another_Loop Pop_Quit: pop AF Quit: RET ;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> P_Left: ld A, (hl) dec A jr nz, P_Boundary ld A, 4 jr P_Boundary P_Right: ld A, (hl) inc A cp 5 jr nz, P_Boundary ld A, 1 P_Boundary: ld (hl), A RET ;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> Draw_P: ld A, (hl) ; 3 dec hl cp 1 ; 2 4 jr z, Down ; 1 cp 2 jr z, Left cp 3 jr z, Up right: dec hl inc (hl) inc hl jr Draw_P_Now Left: dec hl dec (hl) inc hl jr Draw_P_Now Up: inc (hl) jr Draw_P_Now Down: dec (hl) Draw_P_Now: ld C,(hl) ; C = y location dec hl ld B, (hl) ; B = x location CALL Point_On ; now call the routine RET ;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> ; This begins a section of code that is NOT mine. ;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> ;____________________________________________________________________________ ; ; Point_On : Turn on point at b,c ;____________________________________________________________________________ Point_On: PUSH BC CALL FIND_PIXEL LD B,A LD A,($8011) ; Goto line CALL DISP_DELAY OUT ($10),A LD A,($800F) ; Goto byte CALL DISP_DELAY OUT ($10),A CALL DISP_DELAY IN A,($11) ; Get byte CALL DISP_DELAY IN A,($11) OR B ; Set pixel LD B,A LD A,($8011) ; Goto line CALL DISP_DELAY OUT ($10),A LD A,($800F) ; Goto byte CALL DISP_DELAY OUT ($10),A LD A,B CALL DISP_DELAY OUT ($11),A POP BC RET ;____________________________________________________________________________ ; ; GetPixel : Get the value at b,c ;____________________________________________________________________________ GetPixel: PUSH BC CALL FIND_PIXEL ; HL=byte offset in video buffer, A=2^(bit to change) LD B,A LD A,($8011) ; Goto line CALL DISP_DELAY OUT ($10),A LD A,($800F) ; Goto byte CALL DISP_DELAY OUT ($10),A CALL DISP_DELAY ; Get byte IN A,($11) CALL DISP_DELAY IN A,($11) AND B ; Mask, so only one pixel left POP BC RET msgTitle: .db " Tron 1.1 ",0 msgAuthor: .db "By: Scoobie and Eric",0 msgSiteName: .db "The ASM 82 Web Site",0 msgWebSite: .db "http://asm82.home.ml.org",0 msgPressEnter .db "Play - Enter",0 msgQuit .db "Quit - Mode",0 msgSpeed .db " Game Speed ",0 msgTooFast .db "Too Fast",0 msgFast .db "Fast",6h,6h,6h,0 msgNormal .db "Normal",0 msgSlow .db "Slow",6h,6h,6h,0 msgTooSlow .db "Too Slow",0 msgTie .db "It is a draw!",0 msgP1Wins .db "Congratulation player 1!",0 ;msgP2Wins .db "Congratulation player 2!",0 SzArrow .db $CF,$05,0 msgWon .db "You won the game",0 .end