18 call prepareShiftedTiles
64 ld hl,IntrHandlerSmall
76 di ; sadly, we can skip one intr here
78 ; here we have ~14000 tstates to put sprites
80 mainHeliBlidSubr: equ $+1
95 call WinStick.readMoves
96 jr nz,.somethingpressed
106 ; C,A: state (LRUDF; F is #01)
197 ld (mainHeliBlidSubr),hl
246 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
247 ;; build shifted tiles
251 ; tiles are not packed
252 ld de,shiftedTilesBuf
261 ld hl,shiftedTilesBuf
262 ld de,shiftedTilesBuf+6*16*4
265 ld a,3 ; 3 shifts left
268 ; HL: addr of previous tileset
269 ; DE: addr of current tileset
274 ; previous tiles copied, now shift
275 pop hl ; start of the current block
278 ld e,b ; B is always 0 here
293 ex de,hl ; now DE is the new dest address
294 pop hl ; current set address
300 exo_mapbasebits: equ #4000 ; 156 bytes
304 incbin "bdata/tiles_blobs.exo"
306 incbin "bdata/map00.exo"
312 pusherStart: equ $ ; #8800
313 ; max pusher end will be: #8eff
316 scrRowsTable: ds 128*2
319 shiftedTilesBuf: ds 16*4*6*4
323 dw shiftedTilesBuf+0*6*16
324 dw shiftedTilesBuf+1*6*16
325 dw shiftedTilesBuf+2*6*16
326 dw shiftedTilesBuf+3*6*16
331 db 0E5h,0E5h ; 0 : push hl, push hl : 33
332 db 0D5h,0C5h ; 1 : push de, push bc : 01
333 db 0D5h,0D5h ; 2 : push de, push de : 11
334 db 0F5h,0D5h ; 3 : push af, push de : 12
335 db 0C5h,0E5h ; 4 : push bc, push hl : 30
336 db 0E5h,0F5h ; 5 : push hl, push af : 23
337 db 0F5h,0C5h ; 6 : push af, push bc : 02
338 db 0E5h,0C5h ; 7 : push hl, push bc : 03
339 db 0F5h,0E5h ; 8 : push af, push hl : 32
340 db 0F5h,0F5h ; 9 : push af, push af : 22
341 db 0C5h,0C5h ;10 : push bc, push bc : 00
342 db 0D5h,0F5h ;11 : push de, push af : 21
343 db 0C5h,0D5h ;12 : push bc, push de : 10
344 db 0E5h,0D5h ;13 : push hl, push de : 13
345 db 0D5h,0E5h ;14 : push de, push hl : 31
346 db 0C5h,0F5h ;15 : push bc, push af : 20
348 ; jump table for screen pushers
349 ; addr, tilesofs, 2ndtilesofs
353 shiftedTilesOfsTable:
360 plrXOffset: db 0 ; player X offset in the tile (0-7): in 2 pixels
361 plrYOffset: db 0 ; player Y offset in the tile (0-28; step: 4); (0-7): in 2 pixels
372 include "helispr.zas"
388 ; left-to-right stripe
400 org $-1 ; overwrite last 'inc l'
401 ; right-to-left stripe
426 org $-1 ; overwrite last 'dec l'
448 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
449 ;; blit map onto the screen using prebuild 'pushers'
453 ; A is the index in screen line table
454 ; also it is used as 'stop flag', due
455 ; to the fact that we have to render
456 ; only 2/3 of the screen, which is
460 ;ld hl,%0001000100010001
461 ; HL is always 0 for 'pushers'
462 ; we can load it with some 'background' graphix
467 ex af,af' ; switch to 'working' A
468 exx ; switched to 'loop' register set
470 ; calculate number of visible lines in top tile
475 ld (blitMapRowCountVar),a
482 ld (blitMapShiftCmd),a
483 ; calc tilegfx addr (we have set of shifted tiles)
484 ld a,c ; stored plrXOffset
487 add a,shiftedTilesOfsTable%256
489 IF sameseg(shiftedTilesOfsTable, shiftedTilesOfsTable+5)
490 ld h,shiftedTilesOfsTable/256
494 ld a,shiftedTilesOfsTable/256
502 ld (blitMapGfxOfs),hl
506 ld hl,pusherJumpTable
511 ld (pusherAddress),bc
512 ; load tile gfx offset to IY
519 ; load 2nd tile gfx offset to IX
526 ; shift tile gfx addresses according to player Y offset
543 ; HL: tile gfx base address
545 blitMapRowCountVar: equ $+1
547 ; start drawing current row
551 ; load screen line address
553 ld h,scrRowsTable/256
554 ; move to next table item
570 ld sp,hl ; put screen address to SP
572 pusherAddress: equ $+1
573 jp 0 ; self-patching code; jump to 'pusher'
574 blitMapPusherDone: ; 'pushers' will return here
575 ld de,6 ; tiles gfx are 6x16
580 ; move to next map row
581 ; DE: table with 'pusher' addresses and tile offsets
582 ; get next 'pusher' address
587 ld (pusherAddress+1),a
589 blitMapGfxOfs: equ $+1
590 ld bc,0 ; tile grafix offset
591 ; get tile gfx addresses
606 ld b,16 ; 16 lines of next tile row
614 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
615 ;; part of code to get new graphics
616 ;; intended for copying
618 ld (relGfxSavedSP),sp ; 4 bytes
623 ld sp,(relGfxSavedSP) ; 4 bytes
625 codeReloadTileGfxLen: equ $-codeReloadTileGfx
628 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
629 ;; calculate address in the map
653 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
659 ; up one row due to 'next map row' below
662 ld (bldCurMapAddr),hl
665 ld (.bldPusherStartAddrVar),hl
667 ld hl,pusherJumpTable
671 ; store current 'pusher' address
672 .bldPusherStartAddrVar: equ $+1
681 @bldCurMapAddr: equ $+1
692 ld (bldCurMapAddr),hl
693 ; pop 'pusher' address
696 ld (bldCurTileBlockX2Var),a
697 ld b,8 ; 8 bytes/16 tiles
706 jr nz,.bldNonEmptyTile
707 ld a,#E5 ; PUSH HL (2 empty tiles)
710 .bldStorePushAndBackOneMapByte:
713 ; back one map byte, with wrapping
724 ; ---------------------------------------------------------------------------
726 ; put only one tile instead of two
729 jr nz,.bldNonEmptyTileEX
730 ld a,#E5 ; PUSH HL (empty tile)
731 jp .bldStorePushAndBackOneMapByte
737 ld (bldCurTileBlockX2Var),a
738 call bldStoreTileBlockOffset
747 ; ---------------------------------------------------------------------------
753 ld (bldCurTileBlockX2Var),a
754 call bldStoreTileBlockOffset
757 jr .bldWeAreNotEmptyAnyway
769 bldCurTileBlockX2Var: equ $+1
772 jp z,.bldSameTileBlock
774 ld (bldCurTileBlockX2Var),a
775 call bldStoreTileBlockOffset
776 ; copy 'gfx switch' code
779 ld hl,codeReloadTileGfx
780 DUP codeReloadTileGfxLen
787 .bldWeAreNotEmptyAnyway:
805 ; previous map byte, with wrapping
816 dec de ; remove one push (border)
819 jr z,$+3 ; skip next command
820 dec de ; remove another push (map is shifted by one tile)
821 ex de,hl ; HL: 'pusher' end
825 ld (hl),blitMapPusherDone%256
827 ld (hl),blitMapPusherDone/256
829 ld (.bldPusherStartAddrVar),hl ; save this address
830 pop hl ; 'pusher' table
837 jp nz,.bldPusherNextRow
840 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
842 bldStoreTileBlockOffset:
845 ; DE: 'pusher' address
848 ; get tile block offset
849 ld l,tileBlockOffsets%256
853 ld a,tileBlockOffsets/256
862 ; store tile block offset
871 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
903 ;call BuildScrLineTable