Understanding MagicKit Demo Sources

hu, cd, scd, acd, supergrafx discussions.
Post Reply
Ayatollah
Posts: 3
Joined: Tue Oct 21, 2014 9:17 pm

Understanding MagicKit Demo Sources

Post by Ayatollah » Sun Oct 26, 2014 8:22 pm

Hi there.

I have been reading the 4 Chapters of Rich Tutorials and surely have a better understanding now of the whole structure, banks etc. Still struggling with reading through the ASM Codes on the Demos provided in MagicKit but this is mostly because of yet unknown EQU.

What I am doing is working with the STARWAVE Code (seems to be covering the most things at once) and trying to change things etc.
I have stripped out everything but the scroller and it works fine so far. Two things I am not really clear what they do though - maybe somebody here can help:

Code: Select all

	; set interrupt vector

	setvec #HSYNC,hsync_proc
	vec_on #HSYNC
	smb    #7,<irq_m

	; enable HSYNC interrupt

	vreg  #5
	lda   #$cc
	sta   video_data_l
	sta   vdc_crl
This is the Interrupt setting done before the Loop. I get that setvec points the HSYNC to a routine in the demo. This does update a few things like make the water wiggle etc.

What I am not sure is the next part.

vreg #05 - i assume that this is that register (taken from chapter_0.txt on the tutorials)


$05 - (CR) The control register is used to enable/disabled BG or sprites,
auto incrementor, Vblank/hblank/sprite overflow/collision flags.

Why do I write #$CC into video_data_l which is the Data Port (if I am correct)? and the same value to $20F3? It says its the VDC Control Register in EQU.INC?


And my second question is about this routine:

Code: Select all

vsync_proc:
	vreg  #6		; restart the scanline counter on the first
	stw   #$40,video_data	; line
	stw   #$40,<scanline
	rts
The way I read this in the tutorial was store the value of the scanline where you want the vsync to trigger but add #$40 to it before. So if I want the vsync irq to happen at line 80 I would do take i would store b0..

why does this store a word and not a byte?

Thank you and sorry if this might sound like a really lame question ;)

Roland

User avatar
MooZ
Site Admin
Posts: 389
Joined: Sun Jun 22, 2008 3:19 pm
Location: Lvl 3
Contact:

Re: Understanding MagicKit Demo Sources

Post by MooZ » Sun Oct 26, 2014 10:12 pm

$20F3 is a "backup" in RAM for the register. It's a Magic Kit thing.

Code: Select all

vdc_crl = $20F3 ; VDC control register   (copy of)
vdc_crh = $20F4 ;
irq_m   = $20F5 ; interrupt control mask (copy of)
vdc_sr  = $20F6 ; VDC status register    (copy of)
vdc_reg = $20F7 ; VDC register index     (copy of)
#$cc means = enable background, enable sprites, enable vsync and enable hsync.
From Charles' doc:

Code: Select all

 $05 - Control Register (CR)

 D16-D15 : Unused
     D12 : Increment width select (bit 1)
     D11 : Increment width select (bit 0)
     D10 : 1= DRAM refresh enable
      D9 : DISP terminal output mode (bit 1)
      D8 : DISP terminal output mode (bit 0)
      D7 : 1= Background enable
      D6 : 1= Sprite enable 
      D5 : External sync (bit 1)
      D4 : External sync (bit 0)
      D3 : 1= Enable interrupt for vertical blanking
      D2 : 1= Enable interrupt for raster compare
      D1 : 1= Enable interrupt for sprite overflow
      D0 : 1= Enable interrupt for sprite #0 collision
About your 2nd question, it has to store a word because the scanline index may be below 256 (from Charles' doc: "The range of the RCR is 263 lines"). Also, when you write data to VDC you must write a word (or at least write to $0003) to make things work. For example when you write vreg $02, you must write to $0003 in order to increment the internal write pointer.
To be honest I don't know if you really have to write the whole word for vreg $06.

And there's no stupid question! :D

Post Reply