Blood Quest - ZX Spectrum - Development Journal - 2 (English)

 

Blood Quest  - ZX Spectrum - Development Journal - 2 (English)

Hello, I have had some more time to work on Blood Quest for the Speccy.

I did some work on Sprites but I will show them in another update as this one is more about getting information from the map and painting each room on the buffer and then copy the buffer to the screen:


 


The screenshot above shows the room where Zezito will find himself in once he enters the castle. Above the play area I have 2 char lines where the scoreboard will be displayed.

I have coded the following routines:

- ClearScreenAndBuffer

- DrawChar

- DrawTile

- PaintRoom

- CopyBufferToScreen

The screen bellow shows how much raster time(red border) is spent on copying the linear buffer to the screen, as you can see it takes almost one frame so the game will run at 25fps instead of 50.

I am using this Macro to copy each line of the buffer to the screen, the stack is the fasted way to do it:

MACRO mCopyLineFromBufferToScreen, orig, dest
            ld sp,orig
            pop af
            pop bc
            pop de
            pop hl
            exx
            pop bc
            pop de
            pop hl
            ld sp,dest+14
            push hl
            push de
            push bc
            exx
            push hl
            push de
            push bc
            push af

            ld sp,orig+14
            pop af
            pop bc
            pop de
            pop hl
            exx
            pop bc
            ld sp,dest+24
            push bc
            exx
            push hl
            push de
            push bc
            push af         

ENDM

I use it in my CopyBufferToScreen:

CopyBufferToScreen:
                 ld (salvaSP),sp
                 mCopyLineFromBufferToScreen $ebc2,$4044
                 mCopyLineFromBufferToScreen $ebc2+28*1,$4144
                 mCopyLineFromBufferToScreen $ebc2+28*2,$4244
                 mCopyLineFromBufferToScreen $ebc2+28*3,$4344
                 mCopyLineFromBufferToScreen $ebc2+28*4,$4444
                 mCopyLineFromBufferToScreen $ebc2+28*5,$4544
                 mCopyLineFromBufferToScreen $ebc2+28*6,$4644
                 mCopyLineFromBufferToScreen $ebc2+28*7,$4744
                 .
                 
                
                 ld sp,(salvaSP)
                 ret 

 I will have to replace the magic number $ebc2 by a constant so I can change it easily if needed later on.

 


As I wrote in the first entry of the development journal, the game is not divided into levels or screens, in this game I have one map of 60x100 tiles = 6000 bytes, 5*10 rooms of  12x10 tiles. The reason behind this is that I want baddies to move across screens. I will have to store the X and Y Sprite position variables as 16 bits instead of 8.

The PaintRoom routine I am using in this game:

;************************************************************
;*PaintRoom(roomX,roomY)                                    *
;************************************************************ 
;*Rooms are 12x10 tiles                                     *
;************************************************************
;*Returns: -                                                *
;*Destroys: a,bc,de,hl                                      *
;************************************************************ 
PaintRoom:
           ld hl,map
           ld a,(roomY)    ;reg A= y pos of top left corner tile
           ld c,a          ;of the room we want to paint
            
            ;multiply y pos by 60 = 12*5 = width of the map in tiles
           
           ld b,0
           sla c
           rl b
           sla c       
           rl b       ;(y*8) * 4             
           add hl,bc
           sla c       
           rl b       ;(y*8) * 8             
           add hl,bc
           sla c       
           rl b       ;(y*8) * 16                
           add hl,bc   
           sla c       
           rl b       ;(y*8) * 32      = *60
           add hl,bc                                       

           ld a,(roomX)    ;now add the tile's position X to HL
           ld c,a                  
           ld b,0
           add hl,bc

           ld de,0     ;de=x,y where to paint tile on the buffer

PR_paintTile:
           push de      
           push hl         ;save DE and HL as the value of these
                           ;registers will be destroyed by the 
                           ; PaintTile routine.
 
           ld a,(hl)       ;a=tile we want to paint
           cp 18
           jr c,PR_paint
           ;if the tile is 18 or higher paint tile 0 instead
           ;tiles numbered 18 and above are only info markers for 
           ;baddies
           xor a             ;a=0
PR_paint:               
           call PaintTile
    
           pop hl
           pop de            ;restore HL and DE.

           inc hl
           inc d             ;x=x+1
           ld a,12
           cp d
           jr z,PR_nextLine    ;if we have finshed painting one
                               ;line of 12 tiles then move 
                               ;to the next one
           jr PR_paintTile     ;if not then paint the tile

PR_nextLine:
                                  ;process the next line 
                    ld d,0        ;x= 0 as we are in a new line
                    inc e         ;y=y+1 
                    ld bc,60-12   ;one line is 12 tile long
                                  ;and the map is 60 tile wide
                                  ;so we ajust HL accordingly   
                    add hl,bc
                    ld a,10      
                    cp e
                    jr nz,PR_paintTile ;if the 10 lines are not
                                       ;painted yet then paint more
                    ret

The next step is to get information(position(x,y) and type) about the baddies from the map and store it in a table and then display the baddies according to that data.

Cheers,

Iapetus

 


 

 

Comments

Post a Comment

Popular posts from this blog

Blood Quest - Español

Blood Quest - English