- Joined: 26 Apr 2008
- Posts: 16
- Location: France
|
64 colors raster bar routine
Posted: Sun Sep 14, 2008 10:24 am
|
I made a little static raster bar routine, i suppose its not very optimized and actually it miss something but anyway here is it (with a 64 colors raster example, call this in you'r program loop):
WaitVBL:
ld b,$7
-:
; fill the rest with black color
push hl
ld hl,$C000
call VRAMToHL
ld a,$00
out ($be),a
pop hl
djnz jumpBlack
; load first color
ld hl,Raster
ld b,Raster-RasterEnd
rasterLoop:
ld a,(hl)
; change the first color in the palette
push hl
ld hl,$C000
call VRAMToHL
out ($be),a
pop hl
inc hl ; go to the next color value
djnz rasterLoop ; loop over all stored colors
ld b,$7
jumpBlack:
; vbl
in a,($BF)
and $80
jp z,-
ret
; 64 colors of the raster (you can put any value in it though)
Raster:
.db $01, $02, $03, $04, $05, $06, $07, $08, $09, $0A, $0B, $0C, $0D, $0E, $0F, $10, $11, $12, $13, $14, $15, $16, $17, $18, $19, $1A, $1B, $1C, $1D, $1E, $1F, $20, $21, $22, $23, $24, $25, $26, $27, $28, $29, $2A, $2B, $2C, $2D, $2E, $2F, $30, $31, $32, $33, $34, $35, $36, $37, $38, $39, $3A, $3B, $3C, $3D, $3E, $3F
RasterEnd:
I have 2 problems actually to complete this routine:
- I got some strange flickers, i think its because i dont care much right now about where is the beam, i use a tiny counter actually but i think its unefficient.
- For the next step i need to setup a 'beginning' position for the raster bar but i don't know how to calculate it, i tried something but the speed is too fast. :/
If anyone can help me out to ameliorate this routine. :)
rom.zip (3.8 KB)
Rom file to test it (work on Meka/Dega, dunno on real hardware)
|
Quote - I got some strange flickers, i think its because i dont care much right now about where is the beam, i use a tiny counter actually but i think its unefficient.
A simple way to check which scanline you are on is to read the V counter at port $7E. For example
; Wait for line 112
loop:
in a, ($7E)
cp 112
jr nz, loop
If you have completed your color update for one scanline, you can read port $7E, then read it again and wait for the value to change from the last read. By the time it does, you will be on the next scanline and can repeat your color changes.
The SMS can trigger interrupts on different scanlines, but if you are just starting it is easier to work with port $7E.
|