17 ;ld de,shiftedTilesBuf
19 call prepareShiftedTiles
65 ld hl,IntrHandlerSmall
84 di ; sadly, we can skip one intr here
86 ; here we have ~14000 tstates to put sprites
87 ; one heli: ~1910 ticks with PUT; ~2710 ticks with OR
89 mainHeliBlidSubr: equ $+1
108 call WinStick.readMoves
109 jr nz,.somethingpressed
119 ; C,A: state (LRUDF; F is #01)
210 ld (mainHeliBlidSubr),hl
265 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
266 ;; build shifted tiles
270 ; tiles are not packed
271 ld de,shiftedTilesBuf
280 ld hl,shiftedTilesBuf
281 ld de,shiftedTilesBuf+6*16*4
284 ld a,3 ; 3 shifts left
287 ; HL: addr of previous tileset
288 ; DE: addr of current tileset
293 ; previous tiles copied, now shift
294 pop hl ; start of the current block
297 ld e,b ; B is always 0 here
312 ex de,hl ; now DE is the new dest address
313 pop hl ; current set address
319 exo_mapbasebits: equ #4000 ; 156 bytes
325 ; incbin "bdata/tiles_blobs.exo"
328 ;incbin "bdata/map00.exo"
335 ;incbin "maps/map00.bin"
336 incbin "maps/work.bin"
339 pusherStart: equ $ ; #8800
340 ; max pusher end will be: #8eff
343 scrRowsTable: ds 128*2
346 shiftedTilesBuf: ds 16*4*6*4
348 DISPHEX "shiftedTilesBuf: start=#", shiftedTilesBuf, "; end=#", $, "\n"
351 dw shiftedTilesBuf+0*6*16
352 dw shiftedTilesBuf+1*6*16
353 dw shiftedTilesBuf+2*6*16
354 dw shiftedTilesBuf+3*6*16
359 db 0E5h,0E5h ; 0 : push hl, push hl : 33
360 db 0D5h,0C5h ; 1 : push de, push bc : 01
361 db 0D5h,0D5h ; 2 : push de, push de : 11
362 db 0F5h,0D5h ; 3 : push af, push de : 12
363 db 0C5h,0E5h ; 4 : push bc, push hl : 30
364 db 0E5h,0F5h ; 5 : push hl, push af : 23
365 db 0F5h,0C5h ; 6 : push af, push bc : 02
366 db 0E5h,0C5h ; 7 : push hl, push bc : 03
367 db 0F5h,0E5h ; 8 : push af, push hl : 32
368 db 0F5h,0F5h ; 9 : push af, push af : 22
369 db 0C5h,0C5h ;10 : push bc, push bc : 00
370 db 0D5h,0F5h ;11 : push de, push af : 21
371 db 0C5h,0D5h ;12 : push bc, push de : 10
372 db 0E5h,0D5h ;13 : push hl, push de : 13
373 db 0D5h,0E5h ;14 : push de, push hl : 31
374 db 0C5h,0F5h ;15 : push bc, push af : 20
376 ; jump table for screen pushers
377 ; addr, tilesofs, 2ndtilesofs
381 shiftedTilesOfsTable:
388 plrXOffset: db 0 ; player X offset in the tile (0-7): in 2 pixels
389 plrYOffset: db 0 ; player Y offset in the tile (0-28; step: 4); (0-7): in 2 pixels
401 DISPHEX "hspr: start=#", heliframe00, "; end=#", $, "\n"
432 ; left-to-right stripe
452 org $-1 ; overwrite last 'inc l'
453 ; right-to-left stripe
486 org $-1 ; overwrite last 'dec l'
504 DISPHEX "blitHeliAt: start=#", blitHeliAt, "; end=#", $, "\n"
507 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
508 ;; blit map onto the screen using prebuild 'pushers'
512 ; A is the index in screen line table
513 ; also it is used as 'stop flag', due
514 ; to the fact that we have to render
515 ; only 2/3 of the screen, which is
519 ;ld hl,%0001000100010001
520 ; HL is always 0 for 'pushers'
521 ; we can load it with some 'background' graphix
526 ex af,af' ; switch to 'working' A
527 exx ; switched to 'loop' register set
529 ; calculate number of visible lines in top tile
534 ld (blitMapRowCountVar),a
541 ld (blitMapShiftCmd),a
542 ; calc tilegfx addr (we have set of shifted tiles)
543 ld a,c ; stored plrXOffset
546 add a,shiftedTilesOfsTable%256
548 IF sameseg(shiftedTilesOfsTable, shiftedTilesOfsTable+5)
549 ld h,shiftedTilesOfsTable/256
553 ld a,shiftedTilesOfsTable/256
561 ld (blitMapGfxOfs),hl
565 ld hl,pusherJumpTable
570 ld (pusherAddress),bc
571 ; load tile gfx offset to IY
578 ; load 2nd tile gfx offset to IX
585 ; shift tile gfx addresses according to player Y offset
602 ; HL: tile gfx base address
604 blitMapRowCountVar: equ $+1
606 ; start drawing current row
610 ; load screen line address
612 ld h,scrRowsTable/256
613 ; move to next table item
629 ld sp,hl ; put screen address to SP
631 pusherAddress: equ $+1
632 jp 0 ; self-patching code; jump to 'pusher'
633 blitMapPusherDone: ; 'pushers' will return here
634 ld de,6 ; tiles gfx are 6x16
639 ; move to next map row
640 ; DE: table with 'pusher' addresses and tile offsets
641 ; get next 'pusher' address
646 ld (pusherAddress+1),a
648 blitMapGfxOfs: equ $+1
649 ld bc,0 ; tile grafix offset
650 ; get tile gfx addresses
665 ld b,16 ; 16 lines of next tile row
671 DISPHEX "blitMap: start=#", blitMap, "; end=#", $, "\n"
674 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
675 ;; part of code to get new graphics
676 ;; intended for copying
678 ld (relGfxSavedSP),sp ; 4 bytes
683 ld sp,(relGfxSavedSP) ; 4 bytes
685 codeReloadTileGfxLen: equ $-codeReloadTileGfx
688 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
689 ;; calculate address in the map
713 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
719 ; up one row due to 'next map row' below
722 ld (bldCurMapAddr),hl
725 ld (.bldPusherStartAddrVar),hl
727 ld hl,pusherJumpTable
731 ; store current 'pusher' address
732 .bldPusherStartAddrVar: equ $+1
741 @bldCurMapAddr: equ $+1
752 ld (bldCurMapAddr),hl
753 ; pop 'pusher' address
756 ld (bldCurTileBlockX2Var),a
757 ld b,8 ; 8 bytes/16 tiles
766 jr nz,.bldNonEmptyTile
767 ld a,#E5 ; PUSH HL (2 empty tiles)
770 .bldStorePushAndBackOneMapByte:
773 ; back one map byte, with wrapping
784 ; ---------------------------------------------------------------------------
786 ; put only one tile instead of two
789 jr nz,.bldNonEmptyTileEX
790 ld a,#E5 ; PUSH HL (empty tile)
791 jp .bldStorePushAndBackOneMapByte
797 ld (bldCurTileBlockX2Var),a
798 call bldStoreTileBlockOffset
807 ; ---------------------------------------------------------------------------
813 ld (bldCurTileBlockX2Var),a
814 call bldStoreTileBlockOffset
817 jr .bldWeAreNotEmptyAnyway
829 bldCurTileBlockX2Var: equ $+1
832 jp z,.bldSameTileBlock
834 ld (bldCurTileBlockX2Var),a
835 call bldStoreTileBlockOffset
836 ; copy 'gfx switch' code
839 ld hl,codeReloadTileGfx
840 DUP codeReloadTileGfxLen
847 .bldWeAreNotEmptyAnyway:
865 ; previous map byte, with wrapping
876 dec de ; remove one push (border)
879 jr z,$+3 ; skip next command
880 dec de ; remove another push (map is shifted by one tile)
881 ex de,hl ; HL: 'pusher' end
885 ld (hl),blitMapPusherDone%256
887 ld (hl),blitMapPusherDone/256
889 ld (.bldPusherStartAddrVar),hl ; save this address
890 pop hl ; 'pusher' table
897 jp nz,.bldPusherNextRow
900 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
902 bldStoreTileBlockOffset:
905 ; DE: 'pusher' address
908 ; get tile block offset
909 ld l,tileBlockOffsets%256
913 ld a,tileBlockOffsets/256
922 ; store tile block offset
929 DISPHEX "buildPushers: start=#", buildPushers, "; end=#", $, "\n"
932 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
964 ;call BuildScrLineTable