;Tunnel by Adrien BERNARD #include "asm86.h" #include "ti86asm.inc" #include "ti86math.inc" #include "ti86ops.inc" #include "ti86abs.inc" tampon = _plotSScreen .org _asm_exec_ram call _runindicoff call _flushallmenus call _clrLCD set 3,(iy+5) ld ix,$0202 ld (_curRow),ix ld hl,str call _puts ld b,3 disp_str_loop: call disp_str djnz disp_str_loop res 3,(iy+5) call GET_KEY ld ix,road1 ld hl,road ld b,4 ld e,(ix) ld d,40 decompress: ld a,%11111100 or e xor %11111100 cp %00000011 jr z,inc_contrast srl e srl e add a,d sub 1 ld d,a ld (hl),a inc hl djnz decompress inc ix ld e,(ix) ld b,4 jr decompress inc_contrast: ld (hl),0 ld a,($c008) ld (cont),a cp $1f jr z,ini inc a ld ($c008),a out (2),a startgame: ld a,60 ;set up xcar ld (xcar),a ; ld hl,0 ;set up score ld (score),hl ; ld ix,tampon ;load the address of the tampon into ix ld b,55 ini: ld (ix),40 ;set up the tampon inc ix ; djnz ini ; ld de,$fc00 ld a,64 drawroadini: push de ld hl,roadini ld bc,16 ldir pop hl ld de,16 add hl,de push hl pop de sub 1 jr nz,drawroadini restart: ld hl,road ;laod the address of road into hl top: ld a,(hl) ;hl->a cp 0 ;if a=0 jr z,restart ;goto restart ld (tampon),a ;a->tampon ld ix,$fc00 ;load the first address of the graph buffer into ix srl a ;a/8->a srl a ; srl a ; ld b,a ;a->b ldraw: ld (ix),255 ;255->ix inc ix ;inc the address of ix djnz ldraw ;b-1->b :if b>0 :goto ldraw add a,6 ;a+6->a ld c,a ;a->c ld de,6 ;6->de ld a,(hl) ;hl->a ld b,%00000111 ;7->b and b ;a and b ->a cp 0 ;if a=0 jp z,alig ;goto alig ld b,a ;a->b ld a,255 ;255->a deca: srl a ;a/2->a djnz deca ;b-1->b :if b>0 :goto deca cpl ;not a ld (ix),a ;a->ix ld (ix+1),0 ;0->ix+1 cpl ;not a add ix,de ;adds de to the address of ix ld (ix-1),0 ;0->ix-1 ld (ix),a ;a->ix inc ix ;inc the address of ix inc c ;inc c jr part2 ;goto part2 alig: add ix,de ;inc de to the address of ix part2: ld a,16 ;16->a sub c ;a-c->a ld b,a ;a->b ldraw2: ld (ix),255 ;255->ix inc ix ;inc the address of ix djnz ldraw2 ;b-1->b :if b>0 :goto ldraw2 push hl ;scroll all the graph of 1 toward the low ld hl,$ffef ; ld de,$ffff ; ld bc,1008 ; lddr ; pop hl ; inc hl ;inc hl ld a,%10111110 ;initialise the keypad out (1),a ; in a,(1) ;getkey->a cp 191 ;if a=191 (EXIT) jp z,quit ;goto quit cp 253 ;if a=253 (LEFT) jr z,left ;goto left cp 251 ;if a=251 (RIGHT) jr z,right ;goto right ld a,(xcar) ;xcar->a jr suite ;goto suite left: ld a,(xcar) ;xcar->a sub 1 ;a-1->a ld (xcar),a ;a->xcar jr suite ;goto suite right: ld a,(xcar) ;xcar->a inc a ;a+1->a ld (xcar),a ;a->xcar suite: ld e,55 ;55->e push hl ld hl,car ;draw the car call putsprite ; ld hl,tampon ;decal the tampon of 1 ld de,54 ; add hl,de ; ld d,h ; ld e,l ; inc de ; ld bc,55 ; lddr ; pop hl ld ix,tampon ;gets the last element off the tampon ld a,(ix+54) ;and puts it into a sub 1 ld ix,xcar cp (ix) ;if a > xcar jp p,crash ;goto crash add a,42 cp (ix) ;if xcar > a jp m,crash ;goto crash ld ix,(score) ;inc the score inc ix ; ld (score),ix ; jp top ;goto top putsprite: push hl ; Save sprite address ld h,0 ; y*16->hl ld l,e add hl,hl add hl,hl add hl,hl add hl,hl ld e,a ld d,0 srl e ; hl+x/8->hl srl e srl e add hl,de ld de,$FC00 add hl,de ;Add address to graphbuf and %00000111 ; Get the remainder of x/8 cp 0 ; Is this sprite aligned to 8*n,y? jp z,ALIGN ; goto ALIGN pop ix ; ix->sprite ld b,a ld c,8 ; Line loop LILOP: ld a,(ix) ; Get sprite data ld e,0 ; Shift loop push bc SHLOP: srl a rr e djnz SHLOP xor (hl) ld (hl),a ld a,e inc hl xor (hl) ld (hl),a ld de,15 ; Calculate next line address add hl,de inc ix ; Inc spritepointer pop bc dec c jp nz,LILOP ; Next line jp DONE1 ALIGN: ; Blit an aligned sprite to graphbuf pop ix ; de->sprite ld b,8 ld de,16 ALOP1: ld a,(ix) xor (hl) ; xor ld (hl),a inc ix add hl,de djnz ALOP1 DONE1: ret crash: ld ix,$0202 ld (_curRow),ix set 3,(iy+5) ld hl,crashstr call _puts call disp_str ld ix,$0B03 ld (_curRow),ix ld hl,(score) xor a call _DispHL res 3,(iy+5) keyloop: ld a,%10111100 out (1),a in a,(1) cp %10111111 jr z,quit cp %11110111 jp z,startgame cp %11111110 jp z,startgame cp %11011111 jp z,startgame jr keyloop quit: ld a,(cont) ;dec the contraste ld ($c008),a ; out (2),a ; call _CLRLCD ret disp_str: inc ix ld (_curRow),ix call _puts ret xcar: .db 60 score: .dw 0 cont: .db 0 car: .db %01011010 .db %00100100 .db %00100100 .db %01111110 .db %00011000 .db %11100111 .db %00100100 .db %00111100 roadini: .db 255,255,255,255,255,0,0,0,0,0,0,255,255,255,255,255 str: .db " TUNNEL v.1 ",0 .db " programming by: ",0 .db " Adrien BERNARD ",0 .db " ",$5," press " .db "a key ",$cf," ",0 crashstr: .db " CRASH !!! ",0 .db " score:00000 ",0 road1: .db 0,0,0,0,0,85,0,0,0,85,85,170,170,170 .db 85,85,0,0,170,0,170,0,170,0,170,0,0,85 .db 170,170,170,170,170,0,0,170,0,0,0 .db 170,170,170,85,170,85,170,85,85,170,85 .db 170,170,0,0,170,170,170,85,170,170,170 .db 85,0,170,85,0,0,170,170,170,170,170,85 .db 0,170,0,0,170,85,85,0,0,85,0,170,0 .db 170,85,85,0,0,0,0,0,0,170,85,85,0,0,0 .db 170,85,170,85,0,85,85,85,170,85,170,87 road: .db 0 .end