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"
461 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
462 ;; blit map onto the screen using prebuild 'pushers'
466 ; A is the index in screen line table
467 ; also it is used as 'stop flag', due
468 ; to the fact that we have to render
469 ; only 2/3 of the screen, which is
473 ;ld hl,%0001000100010001
474 ; HL is always 0 for 'pushers'
475 ; we can load it with some 'background' graphix
480 ex af,af' ; switch to 'working' A
481 exx ; switched to 'loop' register set
483 ; calculate number of visible lines in top tile
488 ld (blitMapRowCountVar),a
495 ld (blitMapShiftCmd),a
496 ; calc tilegfx addr (we have set of shifted tiles)
497 ld a,c ; stored plrXOffset
500 add a,shiftedTilesOfsTable%256
502 IF sameseg(shiftedTilesOfsTable, shiftedTilesOfsTable+5)
503 ld h,shiftedTilesOfsTable/256
507 ld a,shiftedTilesOfsTable/256
515 ld (blitMapGfxOfs),hl
519 ld hl,pusherJumpTable
524 ld (pusherAddress),bc
525 ; load tile gfx offset to IY
532 ; load 2nd tile gfx offset to IX
539 ; shift tile gfx addresses according to player Y offset
556 ; HL: tile gfx base address
558 blitMapRowCountVar: equ $+1
560 ; start drawing current row
564 ; load screen line address
566 ld h,scrRowsTable/256
567 ; move to next table item
583 ld sp,hl ; put screen address to SP
585 pusherAddress: equ $+1
586 jp 0 ; self-patching code; jump to 'pusher'
587 blitMapPusherDone: ; 'pushers' will return here
588 ld de,6 ; tiles gfx are 6x16
593 ; move to next map row
594 ; DE: table with 'pusher' addresses and tile offsets
595 ; get next 'pusher' address
600 ld (pusherAddress+1),a
602 blitMapGfxOfs: equ $+1
603 ld bc,0 ; tile grafix offset
604 ; get tile gfx addresses
619 ld b,16 ; 16 lines of next tile row
627 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
628 ;; part of code to get new graphics
629 ;; intended for copying
631 ld (relGfxSavedSP),sp ; 4 bytes
636 ld sp,(relGfxSavedSP) ; 4 bytes
638 codeReloadTileGfxLen: equ $-codeReloadTileGfx
641 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
642 ;; calculate address in the map
666 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
672 ; up one row due to 'next map row' below
675 ld (bldCurMapAddr),hl
678 ld (.bldPusherStartAddrVar),hl
680 ld hl,pusherJumpTable
684 ; store current 'pusher' address
685 .bldPusherStartAddrVar: equ $+1
694 @bldCurMapAddr: equ $+1
705 ld (bldCurMapAddr),hl
706 ; pop 'pusher' address
709 ld (bldCurTileBlockX2Var),a
710 ld b,8 ; 8 bytes/16 tiles
719 jr nz,.bldNonEmptyTile
720 ld a,#E5 ; PUSH HL (2 empty tiles)
723 .bldStorePushAndBackOneMapByte:
726 ; back one map byte, with wrapping
737 ; ---------------------------------------------------------------------------
739 ; put only one tile instead of two
742 jr nz,.bldNonEmptyTileEX
743 ld a,#E5 ; PUSH HL (empty tile)
744 jp .bldStorePushAndBackOneMapByte
750 ld (bldCurTileBlockX2Var),a
751 call bldStoreTileBlockOffset
760 ; ---------------------------------------------------------------------------
766 ld (bldCurTileBlockX2Var),a
767 call bldStoreTileBlockOffset
770 jr .bldWeAreNotEmptyAnyway
782 bldCurTileBlockX2Var: equ $+1
785 jp z,.bldSameTileBlock
787 ld (bldCurTileBlockX2Var),a
788 call bldStoreTileBlockOffset
789 ; copy 'gfx switch' code
792 ld hl,codeReloadTileGfx
793 DUP codeReloadTileGfxLen
800 .bldWeAreNotEmptyAnyway:
818 ; previous map byte, with wrapping
829 dec de ; remove one push (border)
832 jr z,$+3 ; skip next command
833 dec de ; remove another push (map is shifted by one tile)
834 ex de,hl ; HL: 'pusher' end
838 ld (hl),blitMapPusherDone%256
840 ld (hl),blitMapPusherDone/256
842 ld (.bldPusherStartAddrVar),hl ; save this address
843 pop hl ; 'pusher' table
850 jp nz,.bldPusherNextRow
853 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
855 bldStoreTileBlockOffset:
858 ; DE: 'pusher' address
861 ; get tile block offset
862 ld l,tileBlockOffsets%256
866 ld a,tileBlockOffsets/256
875 ; store tile block offset
884 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
916 ;call BuildScrLineTable