Language…
17 users online:  AmperSam, Carnalwillow, crocodileman94, DanMario24YT, EvilAdmiralKivi, h4shcat, Hayashi Neru, Jaiden, JezJitzu, MorrieTheMagpie, quantumcoder,  Segment1Zone2, signature_steve, simon.caio,  Tahixham, toady, TonyversoTV - Guests: 261 - Bots: 319
Users: 64,795 (2,378 active)
Latest user: mathew

Comprehensive HDMA Tutorial

ASM CodingHDMA

Originally posted by SnowWhiteYoshiEgg
Thanks a lot for this tutorial - I might have to read it once or twice more, but it certainly gave me a basic idea of how HDMA actually works. I don't really like mindlessly pasting code without knowing at all what it does.


My sentiments exactly. ^_^

Krakenskin Leather Works, my Etsy store.
LordVanya, my art page.
FundamentalEssence, my game development page.
Thank you so much for this tutorial! It really helped me understand how HDMA works without confusing me. Thanks.

My first attempt at porting!

I don't get the some of the HDMA in ram section.

I believe it's the following part I'm messing up.

SEP #$20
LDA $1A
STA !FREERAM+$1
LSR
STA !FREERAM+$3
LSR
STA !FREERAM+$5

When I try inserting it I get the following message,
error: Levelcode.asm: line 86:define not declared (yet?)

I checked the line and this part of the code is their,

STA !FREERAM+$1

I also get a error message for the other 2 as well.
So where am I going wrong?

Sorry I couldn't enter C3 this time, I've just had some much other stuff to do, And I'm also re going over the basics of level design again.
It means you didn't define !FREERAM anywhere. You'll need to put this at the top of levelasm, or whatever you're using:

!FREERAM = $freeRAMaddress


replace $freeRAMaddress with an unused RAM address, preferably a large space.
If you're unsure how much free ram you'll need, ~$400 bytes is enough for most HDMA. Rarely would you need above even $100 bytes for one channel.



Side note: That example I gave sucks. I need to rewrite that portion so the code is actually useful and not indistinguishable from a glitch.

Should've realized people would assemble my example code.. ah well.
okay i think i got that freeram stuff figured out and it inserts the code but nothing happens.
Here's what i got for the init routine,

!FREERAM = $0DC66D
LDX #$0B
LVL1_HDMAINIT:
LDA LVL1BLUE,x
STA !FREERAM,x
DEX
BPL LVL1_HDMAINIT
RTS

LVL1BLUE:
db $4F,$99
db $08,$9A
db $08,$9B
db $08,$9D
db $08,$9E
db $08,$9F
db $00

and for the main routine,

REP #$20 ; 16 bit A
LDA #$0f00 ; $43X0 = 00
STA $4352 ; $43x1 = 00
LDY #$0D
STY $4354
PHK ; get bank
PLY ;
STY $4334 ; store to bank pointer byte
SEP #$20 ; 8 bit A
LDA $1A
STA $0DC66D+$1
LSR
STA $0DC66D+$3
LSR
STA $0DC66D+$5
SEP #$20 ; 8 bit A
LDA #$08 ; Enable HDMA on channel 3
TSB $0D9F ;
RTS ; return


I have tried this and about a zillion other variations.
but nothin, why can't i get a paralax scroll?


Sorry I couldn't enter C3 this time, I've just had some much other stuff to do, And I'm also re going over the basics of level design again.
Originally posted by Mecha_shadow
!FREERAM = $0DC66D


... that's not free RAM, that's a ROM address.

Look in the RAM map for some free RAM addresses
I've been using slogger and tried both
PC offset and LoROM offset it gave me.
But both don't work, does that mean i'm using the wrong program to find free space?
Sorry I couldn't enter C3 this time, I've just had some much other stuff to do, And I'm also re going over the basics of level design again.
You're just using the wrong free space. As Ladida said, slogger outputs free ROM space, while you need free RAM here. Go to the RAM Map and look for some address that says "Empty".


 
THAT'S IT I HAD IT!!!

I found a ram address changed it to that...
DIDN'T WORK

Is this even possible?
I can't learn from an example if it doesn't do anything.
I just can't do it!

Can someone just give me the entire code for a paralax scroll.
I just want some rows on layer 2 to scroll faster than the others.
Even if it's just 3 different rates...

Please someone do this for me. and then tell me what to edit in it so i can get the rows i want to scroll at the speed I want.
Sorry I couldn't enter C3 this time, I've just had some much other stuff to do, And I'm also re going over the basics of level design again.
REP #$20 ; 16 bit A
LDA #$0000 ; $43X0 = 00
STA $4330 ; $43x1 = 00

LDA #LVL1BRIGHT ; get pointer to brightness table
STA $4332 ; store it to low and high byte pointer
PHK ; get bank
PLY ;
STY $4334 ; store to bank pointer byte
SEP #$20 ; 8 bit A
LDA #$08 ; Enable HDMA on channel 3
TSB $0D9F ;
RTS ; return

Can't you put

STZ $4330

??
I own a community of TF2 servers!

ASMT - A new revolutionary ASM system, aka 65c816 ASseMbly Thing
SMWCP - SMW Central Presents a Product- tion long name

frog

http://esolangs.org/wiki/MarioLANG
Yes, if you want. STZ writes two 00's when A is in 16 bit mode (exactly the same as LDA #$0000 STA $whatever).
It works!
This is a really great tutorial, I was able to make my EPIC Level Generator also create a neat HDMA effect because of it.

edit:

$43x7

Does that translate to

$4370??

edit: Also with the HDMATH tool, what is the color bits thing? And also for the pick color option, where you have the whole PC palette box with 239 hues, how come that really does nothing and seems to serve absolutely no purpose?
I own a community of TF2 servers!

ASMT - A new revolutionary ASM system, aka 65c816 ASseMbly Thing
SMWCP - SMW Central Presents a Product- tion long name

frog

http://esolangs.org/wiki/MarioLANG
Quote

$43x7

Does that translate to

$4370??

No, that translates to $4307, $4317, $4327, ect.
If you're using HDMA channel 3 (for example), it'd be $4337.

Quote
edit: Also with the HDMATH tool, what is the color bits thing? And also for the pick color option, where you have the whole PC palette box with 239 hues, how come that really does nothing and seems to serve absolutely no purpose?

I have no clue as I never use that tool. I included a link to it on request. :P
You could convert colors manually if needed.
Ah now I think I get it.
Here's a format for horrible looking per scanline MOSAIC.

REP #$20 ; 16 bit A
LDA #$0600 ; $43X0 = 00 ;Meaning write once
STA $4330 ; $43x1 = 60 ;Meaning we're writing to $2106 the mosaic register
LDA #LVL1MOSAIC ; get pointer to mosaic table
STA $4332 ; store it to low and high byte pointer
PHK ; get bank
PLY ;
STY $4334 ; store to bank pointer byte
SEP #$20 ; 8 bit A
LDA #$08 ; Enable HDMA on channel 3
TSB $0D9F ;
RTS ; return

LVL1MOSAIC: ;The format is Scanline Count / Mosaic Size
db $08,$02 ;xxxxDCBA
db $08,$12 ;A/B/C/D = Affect BG1/BG2/BG3/BG4
db $08,$22 ;xxxx = pixel size, 0=1x1, F=16x16
db $08,$32 ;$02 for example only effects BG 2
db $08,$42
db $08,$52
db $08,$62
db $08,$72
db $08,$82
db $08,$92
db $08,$A2
db $08,$B2
db $08,$C2
db $08,$D2
db $08,$E2
db $08,$F2
db $00

;me goes to test this out with windows
I own a community of TF2 servers!

ASMT - A new revolutionary ASM system, aka 65c816 ASseMbly Thing
SMWCP - SMW Central Presents a Product- tion long name

frog

http://esolangs.org/wiki/MarioLANG

THANKS! I love having HDMA but i never knew how to make it.
can i just put this simple code:
Code
PRINT "INIT ",pc
RTL

PRINT "MAIN ",pc
REP #$20
LDA #$0000
STA $4330
LDA #LVL1BRIGHT
STA $4332
PHK
PLY
STY $4334
SEP #$20
LDA #$08
TSB $0D9F

LVL1BRIGHT:
db $02,$0F
db $02,$0E
db $02,$0D
db $02,$0C
db $02,$0B
db $02,$0A
db $02,$09
db $02,$08
db $00

into a generator sprite? or do i need to make some changes?
(assebling with XKAS or TRASM?)



I might put some sort of signature here once. I guess.
Except for a missing RTL before the LVL1BRIGHT label, the code looks fine. I guess you could use it like this (use xkas for assembly, by the way).


 
HDMA is fun

It's real, it's not mosaic effect in graphic program (look to L3).
In level.asm
How should insert??
Just put an hdma code in levelcode.asm under the level you want it at.
I own a community of TF2 servers!

ASMT - A new revolutionary ASM system, aka 65c816 ASseMbly Thing
SMWCP - SMW Central Presents a Product- tion long name

frog

http://esolangs.org/wiki/MarioLANG

ASM CodingHDMA