6502/65816? What's that for?

Ok, since i got that ASM related thread sticked by Hector (since i’m a lazy bstrd that doesn’t deserve to stick a post) i started getting a feeling that something was missing…i kept on thinking about it until i got it (which took me like 2ns btw, which reminds me that it would be a nice excercize for you ASM newbies to calculate the clockfrequence of my brain then, just to start with something easy i say).
Here you (don’t be foolish, i’ll never post for some help at all, im way too lazy :ulty:) can ask for 6502/65c816 ASM help. Maybe in future we will add a section for MIPS asm too, if we feel you are interested.

Kammedo

what? nobody needs asm help? well, you can always teach me some! :slight_smile: haha, actually I never got the chance to do any asm work, I’d sure love to start messing around with things. any suggestions? oh and…do you remember me?

Post a problem, I’d be glad to take a stab at explaining it for you. :slight_smile:

haha, i would love to have a problem and get help with one, i would, but i only know about registers etc…that’s all. how to make a loop, this and that…little things, i have the art of assembly pdf…in fact, it twas I who turned on chrisRPG of all people to the Art of Assembly book, so there you go. i’d be a genius at this stuff if I had any clue how to apply it to something to entice me into trying more things out. probably… anyhoo, yah heh. hmm, maybe i’ll read that book again, i know i’ve got 65816 documents and some programs on several different cds laying around…but who wants to dig through 800 cds?

I bought “Programming the 6502” off of eBay, read through the chapters covering the “basics”, then got a hold of Yoshi’s NES doc, and stumbled on to King Mike’s DTE tutorial, ann jumped head first into it. I’d recommend you start off with the NES before moving onto the SNES since you’re new to assembly. Once you get NES figured out, it’s just a matter of learning the registers (not the accumulator, index, etc registers) and applying what you’ve learned from working with the NES.

i’m pretty sure i have yoshi’s doc. not sure if it’s the most up-to-date one, or not. i do have mike’s tutorial, i don’t have windhex and i can’t find it anywheres. but yah, i’ll do nes asm first. i also found a log of someone explaining 6502 from irc, and i know i’ve got a log from wombatman explaining some different things…unless it got lost… i’m reading all that right now.

Might want to give this a read, too. I think that’s the official manual, but, even if it’s not, it’s very, very thorough. :slight_smile:

Uhm…what are you missing then? :wink: the rest is only experience :stuck_out_tongue_winking_eye:

that’s just it you know, i’m not missing anything except experience. so i have to actually start playing with things. i’ve got a few games i want to mess with, we’ll see what i learn. ^^

Uhm…you should start with something easy…like a nes game or gb game i suggest

Well i just did the DTE routine tutorial for Ys3 that KingMike had posted up. worked great. Then I added 3-tiles at a time to it, just to be a goof. I wasn’t sure how to multiply by 3 but I managed to get a pretty small multiplication routine added in that worked really good. Lots of fun and I’m starting to get what’s going on a little bit better. Now I need to think up another thing to work on.

;=======================================;
;Title: DBZ: Assault of the Saiyans 	;
;TTE Routine and Implementation		;
;=======================================;
;This code is located in Bank $00. This	;
;more or less replaces the original code;
;for the Japanese dakuten/handakuten	;
;characters. Set up for code at $D7F0	;
;can be found in dbz1_dte_prep.asm	;
;=======================================;

.org $bb00
.mem 8
.index 8

dte_routine:
	cmp #$90		;Since the current character to read is already in the
	bcc end_of_dte		;accumulator we don't need to load it again. First
	clc			;test the character is within the range of the TTE values.
	cmp #$df		;If so we'll move onto the actually decompression, otherwise
	beq run_check		;we'll branch to end_of_dte and store the character in RAM.
	bcs end_of_dte		;Note: Since there isn't anyway to accomplish a A > Mem
				;comparison, we've used a beq to allow for the last TTE entry
				;to be processed.

run_check:
	stx $06fe		;Preserve the current value of X by storing it in unused RAM.
	
	sec
	sbc #$90		;Subtract the start value of the TTE values to use as a base
	clc			;for determining the TTE number.

	sta $06fc		;Will be used later.

	ldx $06fd		;Load X with the test byte.
	beq first_run		;If X = 0, we want the first character.
	bne second_run		;Otherwise, we want the second character or third character.

first_run:
	ldx #$01		;Load X with 1 so we can get the second character next time.
	dec $50			;Decrement the load index. This way the same character will
				;be read AGAIN, but we'll store a value of 1 at $06fd so that
				;the code for the second letter of the trio will be executed
				;the next go through.

	asl a			;Double the accumulator and add the load index offset-thing
	clc			;to get the trio.
	adc $06fc

	jmp dte_char_load

second_run:
	cpx #$02		;If the test byte = 2, then we're on the third character
	beq third_run		;of the trio.

	ldx #$02		;Load X with 2 so we can get the third character next time.
	dec $50			;Decrement the load index once again so we get the third
				;character next time.

	asl a			;Double the accumulator to determine the TTE number.
	clc
	adc #$01		;Add 1 to the accumulator and the index offset thing so that
	adc $06fc		;we get the second character of the TTE set.

	jmp dte_char_load

third_run:
	asl a			;Double the accumulator to determine the trio number.
	clc
	adc #$02		;Add 2 and the index thing so that we get the third character.
	adc $06fc

	ldx #$00		;Reset X so we get the right results next time we encounter a TTE
				;byte.
	stx $06fc		;Reset the temp index offset holder thing.


dte_char_load:
	stx $06fd		;Store test byte.
	tax			;Transfer A to X for the TTE table lookup.
	lda dte_table,x		;Load the accumulator with the character from the dte to be 
				;displayed.
	ldx $06fe		;Restore X.

end_of_dte:
	sta $0605,x		;Before returning to the text read routine, store the tile
				;in RAM where it will be loaded from into VRAM later.

	lda #$01		;Store a space character for what originally was the 
	sta $0604,x		;dakuten, handakuten character. This really isn't necessary,
				;but I've included it as a fail-safe of sorts.

	rts			;Jump back to the end of the DTE Prep routine, and restore
				;the banks before returning to the text read routine.

dte_table:
	.dsl 79			;Build an empty table of 79 ($4F) entries for the DTE look-up
				;table.

(That was written to be compatible with x816.)

No nasty multiplication required (aside from the asl, of course), and it worked perfectly. I ended up ditching this in favor for a huffman compression scheme, as I couldn’t get the compression I wanted. Glad to see you’re getting the hang of it. :slight_smile:

Some code examples
http://www.rastersoft.net/psybiose.zip