Quote from: Jean-Marie on Yesterday at 20:06Only the end of the procedure remains mysterious to me (after the palette setting).
ORG #1B39
prepare_tiles:
LD HL,#1B1F : CALL set_table_of_firmware_inks ;; Set palette.
LD BC,#002C : LD DE,#D7CC : LD HL,#D7CB : LD (HL),#04 : LDIR ;; Fill buffer with vertical stripes (blue-yellow). Why?
LD BC,#0030 : LD DE,#6DC0 : LD HL,#6930 : LDIR ;; Create copy of sprite. This overwrites font data "789".
LD BC,#0040 : LD DE,#6D40 : LD HL,#6CB0 : LDIR ;; Create copy of big flame. This overwrites font data "_012".
LD B,#06 ;; Counter for outer loop.
LD IX,#243E ;; Target address. Table reaches below source address (length: 192, 96 entries).
LD DE,#0006 ;; Source step size.
LD HL,#24FE ;; Source address.
outer_loop: ;;
LD C,#10 ;; Counter for inner loop.
inner_loop: ;;
LD (IX+#01),H : LD (IX+#00),L : INC IX : INC IX ;; Store source address in target entry.
search_marker_loop: ;;
LD A,(HL) : INC HL ;;
CP #D3 : JP Z,marker_found ;;
ADD HL,DE ;; Go to next source record.
JP search_marker_loop ;;
marker_found: ;;
DEC C : JP NZ,inner_loop ;;
DJNZ outer_loop ;;
;; Here:
;; IX - The target pointer has reached the begin of the source at #24FE.
;; HL - The source pointer has reached the begin of sprite data at #2BD2.
;; (#243E) - Target entry 0 points to a value #D3.
;; (#243E+n*2) - Other target entries point to a value behind #D3.
;; ((#243E+n*2)) - a sequence like ( [type] [adr_low] [adr_high] [?] [?] [?] [?] )+
RET
ORG #D600
set_table_of_firmware_inks:
;; HL - Table of 17 firmware inks (for 16 pens and border).
LD E,(HL) ;; E is loaded, but not used.
LD D,#10 ;; Pen counter, 16..1.
pen_loop: ;;
LD A,D : SUB #10 : NEG : LD C,A ;; Pen, 0..15.
LD A,(HL) ;; Read firmware ink from table.
CALL set_pen_to_firmware_ink ;; Set pen to ink.
INC HL ;; Go to next firmware ink.
DEC D : JP NZ,pen_loop ;;
LD C,#10 ;; Finally select border (pen 16).
LD A,(HL) ;; Read final firmware ink.
;; ;; Fall through to subroutine without CALL.
set_pen_to_firmware_ink:
;; A - firmware ink
;; C - pen
PUSH HL ;;
ADD #85 : LD L,A ;; Calculate low byte of address (+#85).
ADC #DE : SUB L : LD H,A ;; Calculate high byte of address (+#DE).
LD A,(HL) ;; Read hardware ink.
POP HL ;;
AND #1F : OR #40 ;; Mask ink and add command bit for Gate Array.
LD B,#7F : OUT (C),C : OUT (C),A ;; Set ink.
;; ;;
RET ;; Jump back to pen loop or to caller of 'set_table_of_firmware_inks'.
0DA9: copyTilesToScreen()
0E28: FOR EACH sprite IN spriteList DO
0E3A: IF sprite IS ExtrasSphere THEN
0E60: copySmallerExtrasSphereSpriteToATemporaryNormalSprite()
----: END IF
AEF0: WITH sprite DO
A7C0: mirrorHorizontally()
9F00: mirrorVertically()
AF04: clipHorizontally()
AF48: clipVertically()
AFC3: copyNonTransparentBytesToScreen()
----: END WITH
0EA9: NEXT
0EB2: drawSpriteWithoutClipping(mine)
0EB9: drawSpriteWithoutClipping(player)
0EE8: drawSpriteWithoutClipping(shield)
DE00: FOR EACH explosion in explosionList
DE2A: getAnimation()
DE11: drawSpriteWithoutClipping(explosion)
DE14: updateAnimation()
----: NEXT
0EEE: swapScreenBuffers()
----:
DF02: SUB drawSpriteWithoutClipping(sprite) : ... : END SUB
ORG #AFC3
;; This routine draws a single sprite after mirroring and clipping have been applied.
;;
;; B - clipped height (full height is 24)
;; C - clipped width (full width is 6)
;; DE' - source address
;; HL' - target address
;; (source_skip-2) - bytes to skip in source for each row
;; (target_skip-2) - bytes to advance target for each row
;; (jump_condition) - set to #CA (JP Z) or #C2 (JP NZ)
draw_sprite:
y_loop: ;; ;;
LD A,C ;; 1 ;;
EXX ;; 1 ;;
;; ;; | ;;
x_loop: ;; | ;; To write one byte, this inner loop takes 17 NOPs.
EX AF,AF' ;; |----- 1 ;; Save A.
LD A,(DE) : INC DE ;; | +-4-+ ;; Load sprite data and update source pointer.
OR A : JR Z,$+3 ;; | 3 4 ;; Is byte opaque?
LD (HL),A ;; | +---2 ;; Write byte.
INC HL ;; | 2 ;; Update target pointer.
EX AF,AF' ;; | 1 ;; Restore A.
DEC A : JP NZ,x_loop ;; |----- 4 ;;
;; ;; | ;;
EX DE,HL ;; 1 ;; Swap registers to allow DE=DE+BC.
LD BC,#0000 :source_skip ;; 3 ;; Skip bytes in source data.
ADD HL,BC ;; 3 ;;
EX DE,HL ;; 1 ;;
;; ;; | ;;
LD BC,#07FA :target_skip ;; 3 ;; Go to next row and skip bytes on screen.
ADD HL,BC ;; 3 ;;
;; ;; | ;;
BIT 6,H ;; 2 ;; Was the screen memory left?
jump_condition: JP Z,$+7 ;; 3 ;;
LD BC,#C040 : ADD HL,BC ;; (6/8) ;; Then correct target pointer.
;; ;; | ;;
EXX ;; 1 ;;
DJNZ y_loop ;; 4-1 ;;
;; ;; ---- ----- ;;
;; ;; 26-1 15|18 ;; (6*(15+18)/2+26+6/8)*24-1 = ~3017 NOPs per sprite.
QuoteMSF version 1.2 Turbo is programmed to launch July 18 for the latest generation, the full version supports projects, together with a demo version with 3 playable characters that are also available for all of the world
Page created in 0.041 seconds with 17 queries.