Random questions about games I study

Ask anything your want about Megadrive/Genesis programming.

Moderator: BigEvilCorporation

Post Reply
tryphon
Very interested
Posts: 316
Joined: Sat Aug 17, 2013 9:38 pm
Location: France

Random questions about games I study

Post by tryphon » Mon Dec 01, 2014 9:23 pm

I saw this piece of code quite frequently on disassemblies of games I study (this is from "Shadow Dancer", but there's the same in "Psy-O-Blade"):

Code: Select all

move.w  #$9340,(a3)
move.w  #$9400,(a3)
move.w  #$95E1,(a3)
move.w  #$9686,(a3)
move.w  #$977F,(a3)
move.w  #$C000,(a3)
move.w  #$0080,-(sp)
move.w  (sp)+,(a3)
a3 is 0xC00004 of course.

I don't understand why the 2 last lines. Is there a reason not to code move.w #$0080, (a3) ? (timing ? if so, why not nops)

Stef
Very interested
Posts: 3131
Joined: Thu Nov 30, 2006 9:46 pm
Location: France - Sevres
Contact:

Post by Stef » Mon Dec 01, 2014 9:49 pm

Yeah timing, because of slow rom (i guess) Sega recommended to always trigger the DMA from a RAM write or you may experience a faulty first word transfer in some case.

tryphon
Very interested
Posts: 316
Joined: Sat Aug 17, 2013 9:38 pm
Location: France

Post by tryphon » Mon Dec 01, 2014 9:58 pm

Thanks! Good to know.

Is it true also for long writes ?

Stef
Very interested
Posts: 3131
Joined: Thu Nov 30, 2006 9:46 pm
Location: France - Sevres
Contact:

Post by Stef » Mon Dec 01, 2014 10:27 pm

The important thing is that the last write BUS operation which trigger the DMA is done from RAM, so same goes for long write yeah.
But anyway today with blazing fast EPROM, you don't need that anymore :p

tryphon
Very interested
Posts: 316
Joined: Sat Aug 17, 2013 9:38 pm
Location: France

Post by tryphon » Mon Dec 01, 2014 10:33 pm

Thanks :)

tryphon
Very interested
Posts: 316
Joined: Sat Aug 17, 2013 9:38 pm
Location: France

Post by tryphon » Tue Dec 02, 2014 3:01 pm

Another question, really dumb this one :

if I understood correctly :

* horizontal scrolling can be specified for a whole plane, or line (1 pixel height) per line, or cell (8 pixels height) per cell. So I assume it uses 2 planes * 2 bytes (case of whole plane), up to 2*1024*2 bytes (case of per line scroll, with max height of a plane = 128 tiles = 1024 lines?) in VRAM

* vertical scroll is similar, except you can only choose between full plane scroll and 2 cells scroll (= 16 pixels ?). That should use 2*64*2 bytes (max plane width = 128 tiles = 64 cells ?) in VSRAM

But the HSCROLL table seems to be 1024 bytes long and the VSRAM would be 80 bytes. So I misunderstood at least one thing...

Unless you specify only the scroll values for the lines and columns that are actually displayed (so 320 lines max and 240 columns, so 15 cells of 16 pixels ?). But numbers don't match either...

Another thing I don't understand : why is there a separate VSRAM and not a HSRAM ? Since the HSCROLL table is larger, it would have made more sense ? :?

Mask of Destiny
Very interested
Posts: 615
Joined: Thu Nov 30, 2006 6:30 am

Post by Mask of Destiny » Tue Dec 02, 2014 4:37 pm

The scroll tables only hold values for the visible display. The numbers don't add up because you have the vertical and horizontal resolution flipped. The display is 240 lines tall and 320 pixels high (in H40 V30 mode anyway). Also the horizontal scroll table isn't really 1024 bytes. It's max size is 960 bytes.

The reason VSRAM has a separate RAM comes down to VRAM bandwidth. You only need to read one value per line per plane for horizontal scrolling, but you need to read 20 times that for the 2 column vertical scroll mode. The Genesis VDP renders the display a line at a time in sync with the video output so VRAM bandwidth within a line is at a premium.

tryphon
Very interested
Posts: 316
Joined: Sat Aug 17, 2013 9:38 pm
Location: France

Post by tryphon » Tue Dec 02, 2014 8:55 pm

Mask of Destiny wrote:The scroll tables only hold values for the visible display. The numbers don't add up because you have the vertical and horizontal resolution flipped. The display is 240 lines tall and 320 pixels high (in H40 V30 mode anyway). Also the horizontal scroll table isn't really 1024 bytes. It's max size is 960 bytes.
Ouch, stupid confusion, sorry :oops:
The reason VSRAM has a separate RAM comes down to VRAM bandwidth. You only need to read one value per line per plane for horizontal scrolling, but you need to read 20 times that for the 2 column vertical scroll mode. The Genesis VDP renders the display a line at a time in sync with the video output so VRAM bandwidth within a line is at a premium.


It makes perfectly sense. Thanks :)

A related question concerning hscroll : couldn't the per-line scroll effect be achieved by modifying the whole plane hscroll value during hblank ?

Chilly Willy
Very interested
Posts: 2984
Joined: Fri Aug 17, 2007 9:33 pm

Post by Chilly Willy » Tue Dec 02, 2014 10:39 pm

tryphon wrote:A related question concerning hscroll : couldn't the per-line scroll effect be achieved by modifying the whole plane hscroll value during hblank ?
Yes, but it's a lot of overhead for no reason. That's the whole point of the hscroll table - to reduce the overhead needed for scrolling more than just the entire display. That allows you to spend that time changing colors on the fly instead. :wink: :D

tryphon
Very interested
Posts: 316
Joined: Sat Aug 17, 2013 9:38 pm
Location: France

Post by tryphon » Wed Dec 03, 2014 4:05 pm

Yes, of course! I had a different very specific goal in mind :)

There are many things I wonder if they are possible using HBLANK. For example, is it possible to draw more sprites than what is theoretically possible (80) by changing the y values during HBLANK ?

Charles MacDonald
Very interested
Posts: 292
Joined: Sat Apr 21, 2007 1:14 am

Post by Charles MacDonald » Wed Dec 03, 2014 4:34 pm

tryphon wrote:Yes, of course! I had a different very specific goal in mind :)

There are many things I wonder if they are possible using HBLANK. For example, is it possible to draw more sprites than what is theoretically possible (80) by changing the y values during HBLANK ?
You can, and games like Castlevania Bloodlines and Sonic 2 in split-screen mode reload the sprite attribute table mid-frame to do that.

I think there's some old forum posts explaining the difficulties involved with doing this, but I can explain it again if you'd like.

tryphon
Very interested
Posts: 316
Joined: Sat Aug 17, 2013 9:38 pm
Location: France

Post by tryphon » Wed Dec 03, 2014 7:02 pm

Thanks for the answer :)

I'd gladly get explanations, but I wouldn't like to take your time away. I made some researchs and suppose you're referring to this thread, it'll be a nice read.

While I'm at it, thank you for your genhw and genvdp documents, which are always a great help :)

Post Reply