; TRON89 made by Endive ; version 1.1 ; ; memory: 3161 bytes include "tios.h" include "util.h" xdef _main xdef _comment xdef _ti89 WriteStr MACRO move.w \3,-(a7) pea \4(pc) move.w \2,-(a7) move.w \1,-(a7) jsr tios::DrawStrXY lea 10(a7),a7 ENDM SetFont MACRO move.w \1,-(a7) jsr tios::FontSetSys lea 2(a7),a7 ENDM _main: jsr util::zap_screen SetFont #2 WriteStr #40,#10,#1,title SetFont #0 WriteStr #55,#25,#1,autor SetFont #1 WriteStr #10,#60,#1,choose WriteStr #35,#70,#1,max mainloop: jsr get_key cmp #268,d0 beq speed1 cmp #269,d0 beq speed2 cmp #270,d0 beq speed3 cmp #271,d0 beq speed4 cmp #272,d0 beq speed5 cmp #264,d0 beq exit bra mainloop speed1: move.l #50000,d0 move.l d0,speed jmp start speed2: move.l #40000,d0 move.l d0,speed jmp start speed3: move.l #30000,d0 move.l d0,speed jmp start speed4: move.l #25000,d0 move.l d0,speed jmp start speed5: move.l #10000,d0 move.l d0,speed start: clr.w var1 clr.w var2 clr.w counter1 clr.w counter2 restart: bsr ini_var ; initialise les variables bsr ini_screen ; initialise l'ecran pea _comment(PC) jsr tios::ST_showHelp lea 4(a7),a7 move.w #0,-(a7) jsr tios::ST_busy lea 2(a7),a7 loop: bsr print_cur ; affiche les trons bsr delay bsr get_key ; quelle touche est presse cmp #124,d0 beq left_1 ; si STO: va a gauche pour le player1 cmp #258,d0 beq right_1 ; si barre a alors va droite pour le player1 cmp #43,d0 beq left_2 ; si + va a gauche pour le player 2 cmp #42,d0 beq right_2 ; si * va a droite pour le player 2 cmp #264,d0 beq exit ; si EXIT EXIT :-) loop_2: bsr move_cur_1 ; update le tron 1 bsr move_cur_2 ; update le tron 2 jmp check ; on verifie si tout va bien exit: jsr util::idle_loop jsr util::clr_scr rts move_cur_1: cmp #1,dir1P beq m_1p cmp #2,dir1P beq m_2p cmp #3,dir1P beq m_3p move.w curX1,d0 sub.w #1,d0 move.w d0,curX1 rts m_1p: move.w curY1,d0 add.w #1,d0 move.w d0,curY1 rts m_2p: move.w curX1,d0 add.w #1,d0 move.w d0,curX1 rts m_3p: move.w curY1,d0 sub.w #1,d0 move.w d0,curY1 rts left_1: sub #1,dir1P cmp #0,dir1P beq left_ap jmp loop_2 left_ap: move.w #4,dir1P jmp loop_2 right_1: add #1,dir1P cmp #5,dir1P beq right_ap jmp loop_2 right_ap: move.w #1,dir1P jmp loop_2 move_cur_2: cmp #1,dir2P beq m_12p cmp #2,dir2P beq m_22p cmp #3,dir2P beq m_32p move.w curX2,d0 sub.w #1,d0 move.w d0,curX2 rts m_12p: move.w curY2,d0 add.w #1,d0 move.w d0,curY2 rts m_22p: move.w curX2,d0 add.w #1,d0 move.w d0,curX2 rts m_32p: move.w curY2,d0 sub.w #1,d0 move.w d0,curY2 rts left_2: sub #1,dir2P cmp #0,dir2P beq left_ap2 bra loop_2 left_ap2: move.w #4,dir2P bra loop_2 right_2: add #1,dir2P cmp #5,dir2P beq right_ap2 bra loop_2 right_ap2: move.w #1,dir2P bra loop_2 print_cur: move.w curX1,d4 move.w curY1,d3 bsr print_pixel move.w curX2,d4 move.w curY2,d3 bsr print_pixel rts print_pixel: move.w d4,-(a7) move.w d3,-(a7) jsr util::pixel_on lea 4(a7),a7 rts ini_var: move.w #46,d3 move.w d3,curX2 move.w #47,d3 move.w d3,curX1 move.w #10,d3 move.w d3,curY1 move.w #150,d3 move.w d3,curY2 move.w #2,d0 move.w d0,dir1P move.w #4,d0 move.w d0,dir2P clr.w lost rts ini_screen: jsr util::clr_scr pea _comment(PC) jsr tios::ST_showHelp lea 4(a7),a7 move.w #0,-(a7) jsr tios::ST_busy lea 2(a7),a7 move.w #93,-(a7) move.w #159,-(a7) move.w #00,-(a7) move.w #00,-(a7) jsr util::frame_rect lea 8(a7),a7 bsr print_cur rts delay: move.l speed,d5 delay_loop: nop dbra d5,delay_loop rts get_key: tst.w tios::kb_vars+$1E bne.s apres rts apres: move.w tios::kb_vars+$1E,d0 clr.w tios::kb_vars+$1E rts check: move.w curX1,d4 move.w curY1,d3 move.w d4,-(a7) move.w d3,-(a7) jsr util::find_pixel lea 4(a7),a7 btst d0,(a0) bne check1 check_2: move.w curX2,d4 move.w curY2,d3 move.w d4,-(a7) move.w d3,-(a7) jsr util::find_pixel lea 4(a7),a7 btst d0,(a0) bne lost2 cmp #1,lost beq lost1 bsr print_cur jmp loop check1: move.w #1,d0 move.w d0,lost bra check_2 lost1: SetFont #2 WriteStr #20,#10,#1,P1_lost add #$01,var2 move.w counter2,d6 mulu #4,d6 move.w var2,d0 add.w d6,d0 divu #10,d0 clr.w d0 cmp.l #$0,d0 bne pre_wait add #6,var2 add #1,counter2 jmp pre_wait lost2: cmp #1,lost beq lost12 SetFont #2 WriteStr #20,#10,#1,P2_lost add #$01,var1 move.w counter1,d6 mulu #4,d6 move.w var1,d0 add.w d6,d0 divu #10,d0 clr.w d0 cmp.l #$0,d0 bne pre_wait add #6,var1 add #1,counter1 jmp pre_wait lost12: SetFont #2 WriteStr #5,#10,#1,P12_lost pre_wait: SetFont #0 WriteStr #1,#88,#3,blank WriteStr #1,#88,#1,P1_score WriteStr #125,#88,#3,blank WriteStr #125,#88,#1,P2_score bsr dec_print1 bsr dec_print2 wait: bsr get_key cmp #13,d0 beq restart cmp #264,d0 beq exit jmp wait ;лллллллллллллллл Put_DEC лллллллллллллллллллл dec_print1: move.w var2,d0 move.l #55,d1 move.l #17,d2 move.l #1,d4 bsr put_hex rts dec_print2: move.w var1,d0 move.l #55,d1 move.l #2,d2 move.l #1,d4 bsr put_hex rts putchar: movem.l d1-d3/a0-a1,-(a7) move.l d0,d3 lsl.l #2,d0 add.l d3,d0 lea numbers(pc),a0 ; a0 -> numbers + 8*char add.l d0,a0 move.l #LCD_MEM,a1 ; a1 -> LCD + 240*row + column lsl.l #4,d1 move.l d1,d0 lsl.l #2,d0 sub.l d1,d0 add.l d2,d0 add.l d0,a1 move.l #30,d1 ; 30 bytes per pixel row move.w #4,d2 ; 8 bytes per character putcharloop: move.b (a0)+,(a1) add.l d1,a1 dbf.w d2,putcharloop movem.l (a7)+,d1-d3/a0-a1 rts put_hex: movem.l d3-d5,-(a7) put_hex_loop: move.l d0,d5 ; save number move.l d4,d3 lsl.l #2,d3 ; d3 = 4*loopcount (# bits to shift) lsr.l d3,d0 and.l #$0000000F,d0 bsr putchar move.l d5,d0 ; restore number addq.l #1,d2 ; increment column dbf.w d4,put_hex_loop movem.l (a7)+,d3-d5 rts ;***************************************************** ; NUMBER CHARACTER DATA ;***************************************************** numbers: dc.b %00000010 * 0 dc.b %00000101 dc.b %00000101 dc.b %00000101 dc.b %00000010 dc.b %00000010 * 1 dc.b %00000110 dc.b %00000010 dc.b %00000010 dc.b %00000111 dc.b %00000110 * 2 dc.b %00000001 dc.b %00000010 dc.b %00000100 dc.b %00000111 dc.b %00000110 * 3 dc.b %00000001 dc.b %00000010 dc.b %00000001 dc.b %00000110 dc.b %00000100 * 4 dc.b %00000101 dc.b %00000111 dc.b %00000001 dc.b %00000001 dc.b %00000111 * 5 dc.b %00000100 dc.b %00000110 dc.b %00000001 dc.b %00000110 dc.b %00000011 * 6 dc.b %00000100 dc.b %00000111 dc.b %00000101 dc.b %00000111 dc.b %00000111 * 7 dc.b %00000001 dc.b %00000010 dc.b %00000100 dc.b %00000100 dc.b %00000111 * 8 dc.b %00000101 dc.b %00000111 dc.b %00000101 dc.b %00000111 dc.b %00000111 * 9 dc.b %00000101 dc.b %00000111 dc.b %00000001 dc.b %00000110 title dc.b "TRON89 v1.1",0 autor dc.b "made by Endive",0 choose dc.b "choose your speed: F1-F5",0 max dc.b "(max speed F5!)",0 P1_score dc.b "P1:",0 P2_score dc.b "P2:",0 P1_lost dc.b "PLAYER 1 LOST!!",0 P2_lost dc.b "PLAYER 2 LOST!!",0 P12_lost dc.b "PLAYER 1 AND 2 DIED",0 blank dc.b " ",0 speed dc.l 0 key dc.l 0 curX1 dc.w 0 curY1 dc.w 0 curX2 dc.w 0 curY2 dc.w 0 lost dc.w 0 dir1P dc.w 0 dir2P dc.w 0 var dc.w 0 var1 dc.w 0 var2 dc.w 0 counter dc.w 0 counter1 dc.w 0 counter2 dc.w 0 _comment dc.b "tron89 v1.0 made by endive ",0 end