Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Stack Bug in ZXB 1.2.5-r1489 ?
#16
spritebuffer.bas: I made a small routine to take care of the background and use it with the previous sprite.bas routine. It has zero optimization (note the repeated code, that is also used in the sprite routine) but I just wanted something working.

Code:
SUB cpbuffer (xd as ubyte,yd as ubyte,buff as Uinteger)
POKE @buffer,xd:POKE @buffer+1,yd: POKE uinteger @buffer+5,buff
gosub copybuffer
END SUB

SUB rstbuffer (xd as ubyte,yd as ubyte,buff as Uinteger)
POKE @buffer,xd:POKE @buffer+1,yd: POKE uinteger @buffer+5,buff
gosub restorebuffer
END SUB

SUB cpattr (xd as ubyte, yd as ubyte, buff as Uinteger)
LET xattr=INT (xd/8): LET yattr=INT (yd/8): LET dirattr=22528+(32*xattr)+yattr
'POKE uinteger @buffer+5,buff
POKE buff,PEEK dirattr: POKE buff+1,PEEK (dirattr+1): POKE buff+2,PEEK (dirattr+2)
POKE buff+3,PEEK (dirattr+32): POKE buff+4,PEEK (dirattr+33): POKE buff+5,PEEK (dirattr+34)
POKE buff+6,PEEK (dirattr+64): POKE buff+7,PEEK (dirattr+65): POKE buff+8,PEEK (dirattr+66)
END SUB

SUB rstattr (xd as ubyte, yd as ubyte, buff as Uinteger)
LET xattr=INT (xd/8): LET yattr=INT (yd/8): LET dirattr=22528+(32*xattr)+yattr
'POKE uinteger @buffer+5,buff
POKE dirattr,PEEK buff: POKE dirattr+1,PEEK (buff+1): POKE dirattr+2,PEEK (buff+2)
POKE dirattr+32,PEEK (buff+3): POKE dirattr+33,PEEK (buff+4): POKE dirattr+34,PEEK (buff+5)
POKE dirattr+64,PEEK (buff+6): POKE dirattr+65,PEEK (buff+7): POKE dirattr+66,PEEK (buff+8)
END SUB



end
buffer:
ASM
xcoord: defb 0
ycoord: defb 0
altura: defb 0
gfx: defw 0
buf: defw 0
END ASM
copybuffer:
ASM
copybuffer:
;rutina para copiar algo en algun sitio, más o menos.
; This routine returns a screen address for (c, b) in de.
       ld bc,(xcoord)
scadd3: ld a,c              ; get vertical position.
       and 7               ; line 0-7 within character square.
       add a,64            ; 64 * 256 = 16384 (Start of screen display)
       ld d,a              ; line * 256.
       ld a,c              ; get vertical again.
       rrca                ; multiply by 32.
       rrca
       rrca
       and 24              ; high byte of segment displacement.
       add a,d             ; add to existing screen high byte.
       ld d,a              ; that's the high byte sorted.
       ld a,c              ; 8 character squares per segment.
       rlca                ; 8 pixels per cell, mulplied by 4 = 32.
       rlca                ; cell x 32 gives position within segment.
       and 224             ; make sure it's a multiple of 32.
       ld e,a              ; vertical coordinate calculation done.
       ld a,b              ; y coordinate.
       rrca                ; only need to divide by 8.
       rrca
       rrca
       and 31              ; squares 0 - 31 across screen.
       add a,e             ; add to total so far.
       ld e,a              ; hl = address of screen.
       ld (gfx),de
        ld b,16
        ld HL,(gfx)  ;apuntar a la primera celda de la pantalla
        ld DE,(buf)        ;apuntar al buffer
bucle3:  ld a,(HL)         ;capturo el grafico en a
        ;LD C,a            ;y lo paso a C
        ;ld a,(HL)         ;cargo en a el contenido de la celda destino
        ;xor C             ;xoreo con lo que traigo del grafico
        ld (DE),a         ;lo pinto en   (hasta aquí sale xdd)
        inc L
        inc E
        ld a,(HL)
        ld (DE),a
        inc L
        inc E
        ld a,(HL)
        ld (DE),a
        dec L
        dec L
        call uphl
        inc E
        djnz bucle3
ret
END ASM
restorebuffer:
ASM
restorebuffer:
;rutina para copiar algo en algun sitio, más o menos.
; This routine returns a screen address for (c, b) in de.
       ld bc,(xcoord)
scadd2: ld a,c              ; get vertical position.
       and 7               ; line 0-7 within character square.
       add a,64            ; 64 * 256 = 16384 (Start of screen display)
       ld d,a              ; line * 256.
       ld a,c              ; get vertical again.
       rrca                ; multiply by 32.
       rrca
       rrca
       and 24              ; high byte of segment displacement.
       add a,d             ; add to existing screen high byte.
       ld d,a              ; that's the high byte sorted.
       ld a,c              ; 8 character squares per segment.
       rlca                ; 8 pixels per cell, mulplied by 4 = 32.
       rlca                ; cell x 32 gives position within segment.
       and 224             ; make sure it's a multiple of 32.
       ld e,a              ; vertical coordinate calculation done.
       ld a,b              ; y coordinate.
       rrca                ; only need to divide by 8.
       rrca
       rrca
       and 31              ; squares 0 - 31 across screen.
       add a,e             ; add to total so far.
       ld e,a              ; hl = address of screen.
       ld (gfx),de

        ld b,16
        ld HL,(gfx)  ;apuntar a la primera celda del destino
        ld DE,(buf)        ;apuntar al origen
bucle2:  ld a,(DE)         ;capturo el grafico en a
        ;LD C,a            ;y lo paso a C
        ;ld a,(HL)         ;cargo en a el contenido de la celda destino
        ;xor C             ;xoreo con lo que traigo del grafico
        ld (HL),a         ;lo pinto en la pantalla  (hasta aquí sale xdd)
        inc L
        inc E
        ld a,(DE)
        ld (HL),a
        inc L
        inc E
        ld a,(DE)
        ld (HL),a
        dec L
        dec L
        call uphl
        inc E
        djnz bucle2
ret

uphl:
    inc h
    ld a,h
    and 7
    ret nz
    ld a,l
    add a,32
    ld l,a
    ret c
    ld a,h
    sub 8
    ld h,a
    ret

END ASM
Reply
#17
apenao Wrote:spritebuffer.bas: I made a small routine to take care of the background and use it with the previous sprite.bas routine. It has zero optimization (note the repeated code, that is copied from J. Cauldwells code used in the sprite routine) but I just wanted something working.

Code:
SUB cpbuffer (xd as ubyte,yd as ubyte,buff as Uinteger)
POKE @buffer,xd:POKE @buffer+1,yd: POKE uinteger @buffer+5,buff
gosub copybuffer
END SUB

SUB rstbuffer (xd as ubyte,yd as ubyte,buff as Uinteger)
POKE @buffer,xd:POKE @buffer+1,yd: POKE uinteger @buffer+5,buff
gosub restorebuffer
END SUB

SUB cpattr (xd as ubyte, yd as ubyte, buff as Uinteger)
LET xattr=INT (xd/8): LET yattr=INT (yd/8): LET dirattr=22528+(32*xattr)+yattr
'POKE uinteger @buffer+5,buff
POKE buff,PEEK dirattr: POKE buff+1,PEEK (dirattr+1): POKE buff+2,PEEK (dirattr+2)
POKE buff+3,PEEK (dirattr+32): POKE buff+4,PEEK (dirattr+33): POKE buff+5,PEEK (dirattr+34)
POKE buff+6,PEEK (dirattr+64): POKE buff+7,PEEK (dirattr+65): POKE buff+8,PEEK (dirattr+66)
END SUB

SUB rstattr (xd as ubyte, yd as ubyte, buff as Uinteger)
LET xattr=INT (xd/8): LET yattr=INT (yd/8): LET dirattr=22528+(32*xattr)+yattr
'POKE uinteger @buffer+5,buff
POKE dirattr,PEEK buff: POKE dirattr+1,PEEK (buff+1): POKE dirattr+2,PEEK (buff+2)
POKE dirattr+32,PEEK (buff+3): POKE dirattr+33,PEEK (buff+4): POKE dirattr+34,PEEK (buff+5)
POKE dirattr+64,PEEK (buff+6): POKE dirattr+65,PEEK (buff+7): POKE dirattr+66,PEEK (buff+8)
END SUB



end
buffer:
ASM
xcoord: defb 0
ycoord: defb 0
altura: defb 0
gfx: defw 0
buf: defw 0
END ASM
copybuffer:
ASM
copybuffer:
;rutina para copiar algo en algun sitio, más o menos.
; This routine returns a screen address for (c, b) in de.
       ld bc,(xcoord)
scadd3: ld a,c              ; get vertical position.
       and 7               ; line 0-7 within character square.
       add a,64            ; 64 * 256 = 16384 (Start of screen display)
       ld d,a              ; line * 256.
       ld a,c              ; get vertical again.
       rrca                ; multiply by 32.
       rrca
       rrca
       and 24              ; high byte of segment displacement.
       add a,d             ; add to existing screen high byte.
       ld d,a              ; that's the high byte sorted.
       ld a,c              ; 8 character squares per segment.
       rlca                ; 8 pixels per cell, mulplied by 4 = 32.
       rlca                ; cell x 32 gives position within segment.
       and 224             ; make sure it's a multiple of 32.
       ld e,a              ; vertical coordinate calculation done.
       ld a,b              ; y coordinate.
       rrca                ; only need to divide by 8.
       rrca
       rrca
       and 31              ; squares 0 - 31 across screen.
       add a,e             ; add to total so far.
       ld e,a              ; hl = address of screen.
       ld (gfx),de
        ld b,16
        ld HL,(gfx)  ;apuntar a la primera celda de la pantalla
        ld DE,(buf)        ;apuntar al buffer
bucle3:  ld a,(HL)         ;capturo el grafico en a
        ;LD C,a            ;y lo paso a C
        ;ld a,(HL)         ;cargo en a el contenido de la celda destino
        ;xor C             ;xoreo con lo que traigo del grafico
        ld (DE),a         ;lo pinto en   (hasta aquí sale xdd)
        inc L
        inc E
        ld a,(HL)
        ld (DE),a
        inc L
        inc E
        ld a,(HL)
        ld (DE),a
        dec L
        dec L
        call uphl
        inc E
        djnz bucle3
ret
END ASM
restorebuffer:
ASM
restorebuffer:
;rutina para copiar algo en algun sitio, más o menos.
; This routine returns a screen address for (c, b) in de.
       ld bc,(xcoord)
scadd2: ld a,c              ; get vertical position.
       and 7               ; line 0-7 within character square.
       add a,64            ; 64 * 256 = 16384 (Start of screen display)
       ld d,a              ; line * 256.
       ld a,c              ; get vertical again.
       rrca                ; multiply by 32.
       rrca
       rrca
       and 24              ; high byte of segment displacement.
       add a,d             ; add to existing screen high byte.
       ld d,a              ; that's the high byte sorted.
       ld a,c              ; 8 character squares per segment.
       rlca                ; 8 pixels per cell, mulplied by 4 = 32.
       rlca                ; cell x 32 gives position within segment.
       and 224             ; make sure it's a multiple of 32.
       ld e,a              ; vertical coordinate calculation done.
       ld a,b              ; y coordinate.
       rrca                ; only need to divide by 8.
       rrca
       rrca
       and 31              ; squares 0 - 31 across screen.
       add a,e             ; add to total so far.
       ld e,a              ; hl = address of screen.
       ld (gfx),de

        ld b,16
        ld HL,(gfx)  ;apuntar a la primera celda del destino
        ld DE,(buf)        ;apuntar al origen
bucle2:  ld a,(DE)         ;capturo el grafico en a
        ;LD C,a            ;y lo paso a C
        ;ld a,(HL)         ;cargo en a el contenido de la celda destino
        ;xor C             ;xoreo con lo que traigo del grafico
        ld (HL),a         ;lo pinto en la pantalla  (hasta aquí sale xdd)
        inc L
        inc E
        ld a,(DE)
        ld (HL),a
        inc L
        inc E
        ld a,(DE)
        ld (HL),a
        dec L
        dec L
        call uphl
        inc E
        djnz bucle2
ret

uphl:
    inc h
    ld a,h
    and 7
    ret nz
    ld a,l
    add a,32
    ld l,a
    ret c
    ld a,h
    sub 8
    ld h,a
    ret

END ASM
Reply
#18
Links to download the .tzx and the binary files:

http://www.mediafire.com/file/muq0moygqim/COLCLASH.TZX

http://www.mediafire.com/file/ig1nom3lwn1/marbella.rle

http://www.mediafire.com/file/nwmeoukzy2n/ny.rle

http://www.mediafire.com/file/4kzrqlyzwym/partenon.rle

http://www.mediafire.com/file/dhynemqdmdm/pascua.rle

http://www.mediafire.com/file/yzmdd2emni...ighter.BIN

http://www.mediafire.com/file/nj51v2w3t5...ehedge.rle


I think that's all
Reply
#19
boriel Wrote:
apenao Wrote:Here goes the .bas listing of the program. I'll post the custom library files following this. I have to think of a way to send the binary files.
You should be able to upload .zip files attached to the previous message (I'm enabling them). :wink:

I've just seen this. If you can't download the files from mediafire, I'll ZIP them and attach them in the first message.
Reply
#20
apenao Wrote:
boriel Wrote:
apenao Wrote:Here goes the .bas listing of the program. I'll post the custom library files following this. I have to think of a way to send the binary files.
You should be able to upload .zip files attached to the previous message (I'm enabling them). :wink:

I've just seen this. If you can't download the files from mediafire, I'll ZIP them and attach them in the first message.
It's Ok. I have reproduced the compiler bug. :roll:
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)