My next issue I'm having is DMA. I've been trying to learn how to do this before moving on to other parts of the system. I've spent a couple of days or so now trying to work this out myself referring to sega2 and genvdp.txt
Even compared against TMEE's DMA code from the TMEGALIB. Only real difference I noted is that you seem to set VDP destination addr high and addr low before addr middle. Is that some weird requirement or was it just more efficient to code it that way for the subroutine input data registers?
I checked over my code many times and I'm satisfying all the requirements specified in sega2 to perform a VRAM fill (or so I think). Here's the command chain I'm using to try fill plane a with 0x0023 (Actually want to fill with NUL but it makes more sense to try fill with an ASCII character first so I can see if it's working on display without having to debug, and I'm only trying to fill plane a for now until I know how to work it properly!):
Code: Select all
movea.l #$C00000, a4 ; a4 points to vdpdata
movea.l #$C00004, a5 ; a5 points to vdpctrl
move.w #$8154, (a5) ; DISPLAY and DMA on. VINT off. 28-cell mode.
move.w #$8F01, (a5) ; VRAM destination auto-increment (should this be 1 or 2?)
move.w #$9300, (a5) ; sets dma length (low) to 0x00
move.w #$9420, (a5) ; sets dma length (high) to 0x20. Total length 0x2000 (ALL of plane a)
move.w #$9780, (a5) ; sets dma 'source high' to 'fill using constant' mode
move.w #$9600, (a5) ; clearing dma source mid just incase
move.w #$9500, (a5) ; clearing dma source low just incase
move.l #$40000003, (a5); VRAM addr: C000
; genvdp.txt says the above write triggers dma,
; but it doesn't have the constant until following vram write, see next line
move.w #$0023, (a4) ; move "#" into VDP_DATA to trigger DMA FILL
; dma should begin just now after write complete, right?
Also in my code all the setting of VDP registers, and vdpdata,vdpcontrol to a4,a5 is done at the start of the ROM using a table, I've just tried coding them all inline here in case some code inbetween is somehow changing them, shouldn't be the case, and also so you don't have to look through the full code, unless you might have to anyway? Well it's hardly massive being hello world! XD
Checked in Exodus (which is brilliant!) and KMod (also very useful), and the 0x0023 is being written to VRAM:C000, just no DMA. (!?)
Thanks for any and all help guys
I'm at a complete loss! Let's see if I can figure this out before someone posts what I'm doing wrong. GAME ON
edit: Originally I was trying to fill with 0x23, then realised I actually need to format it 0x0023, so updated that, still not triggering DMA, of course it should trigger regardless of what the data represents. Just overwriting first letter with #
Also, would this work:
move.b 0x23, (a4)
Would it be interpreted 0x0023, 0x2323, or is it an invalid VDP write?
edit2:
Aha, I forgot you needed to set bit 7 in the data port write to trigger DMA. I thought it was ALWAYS 0 because of page 12 of sega2, where the table specifies CD4 and CD5 are 0 regardless of access mode, when perhaps it should say DMA in the CD5 column...
This brings the question: when is CD4 set, if ever?
Now plane a seems to be getting blanked in stead of # everywhere so I still have something to sort out...