kammedo's (and others) ASM related thingies

Here I’ll (or you be able to) post every kind of news/information i stumble upon about ASM coding and Hardware in general…

Kammedo

:thinking:

If you are into SNES programming or SNES emulation you surely can’t miss the latest from Byuu’s thread about SNES timing …
http://board.zsnes.com/phpBB2/viewtopic.php?t=1700&start=100
or if you like to check out his page:

http://www.setsuna.the2d.com/

Kammedo

http://psx.rules.org/

The most comprehensive information I’ve been able to find on the playstation. Should prove to be quite helpful if you’re interested in the playstation.

One of the most impressive sites with Hardware / development information around :

Dextrose

Here you’ll find tons of information that kover the 3rd generation of consoles (PS, N64) and the 4th gen (GC, XBOX).

Including this for the helluvit!

;MEGAMI TENSEI DTE ROUTINE
;For compilation with X816
;Note that the following three lines are NECESSARY because X816 is a compiler for
;the SUPER NES and NOT the normal NES. The following will basically "fool" x816 into
;compiling NES code instead of SNES code.
;NOTE: Manually insert a JSR $RoutineAddress at $AF24. Do not forget to add $10 to this
;address to compensate for the iNES header!

.org $8000
.mem 8
.index 8

DTE_Routine:
  LDY $0658        ;This was the first command I overwrote with the jump to the routine.
  LDA ($BE),Y      ;This is the second.
  CMP #$30         ;DTE Range compare 1
  BCC End          ;If A is < #$30, skip DTE (Branch if carry clear) 
  CLC              ;Clear the carry flag - we get here because
  CMP #$80         ;DTE Range Compare 2
  BCS End          ;If A is >=#$80, skip DTE (Branch if carry set)
                   ;If we get past the upper and lower bound range compares, we have DTE!
RunCheck:
  STX $07FE        ;Store X temporarily to THE DEPTHS OF UNUSED RAM
  SEC
  SBC #$30
  CLC
  LDX $07FF        ;Load X with a test byte from THE DEPTHS OF UNUSED RAM
  CPX #$9D         ;Compare it with test=true (#$9D in this case)
  BEQ SecondRun    ;If test=true, we're printing the second character
  BNE FirstRun     ;If test=false, we're printing the FIRST character.
  

FirstRun:          ;For outputting the first character...
  LDX #$9D         ;Load X with Test=true
  DEC $0658        ;Decrement load index (which gets transferred into Y)
  ASL A            ;Double A to get DTE Pair Number
  JMP Base_Routine ;Jump to the shared bits of the routine (4C2780)

SecondRun:
  ASL A            ;Double A for DTE Pair Number
  CLC              ;Clear the carry cuz we're gonna add
  ADC #$01         ;Increment the accumulator
                   ;A is now the index location of the second byte in the DTE Pair.
  LDX #$00         ;Load X with Test=FALSE

Base_Routine:
  STX $07FF        ;Store test byte to THE DEPTHS OF UNUSED RAM
  TAX              ;Transer A to X for the DTE table lookup
  LDA $DTETable,X  ;Load A with where ever your DTE table happens to be,X
  LDX $07FE        ;Restore X from before routine

End:
  JMP $AF29        ;Jump back to the routine
  

Create_DTE_Table:
.DSW 80            ;Create an 80 ($50) byte empty DTE table to be later filled in
                   ;This gets put -immediately- after the routine.

I can testify as to the usefulness of that code. :smiley:

Impressive ! :cool:

There’s a RS2 routine code i stumbled upon today…i “think” i got it from LordTech, the guy sitting on the Throne over at Wakdhacks…


elite dialog routine for romancing saga 2
hell yes! :D


;; Store 0x40 zeroes to $7FA492 (clear out the memory we need!)
$C0/CC2E: A2 00 00     LDX #$0000                ;; load X from $0000 (start count at zero)
$C0/CC31: C2 20        REP #$20                  ;; set to 16 bit accumulator mode
$C0/CC33: 9E 92 A4     STZ $A492,X [$7F:A492]    ;; store zero to memory
$C0/CC36: E8           INX                       ;; increment X
$C0/CC37: E8           INX                       ;; increment X (increment the count by 2)
$C0/CC38: E0 40 00     CPX #$0040                ;; compare x with $0040
$C0/CC3B: D0 F6        BNE $F6 [$CC33]           ;; branch to $CC33 if result is not equal ($F6 is a relative address)
									(stop when count hits 0x40)

$C0/CC3D: E2 20        SEP #$20                  ;; set to 8 bit accumulator mode
$C0/CC3F: A6 B4        LDX $B4 [$00:13B4]        ;; Load X from $B4 (since X is the offset of where it reads...
									so too must be $B4, therefore its used to tell what letter to load)
$C0/CC41: A0 00 00     LDY #$0000                ;; set Y to #$0000

$C0/CC44: BF 00 00 D4  LDA $D40000,X [$D4:0370]  ;; load accumulator from $D40000+X (read the left half)
$C0/CC48: EB           XBA                       ;; swap low and high bytes of accumulator
$C0/CC49: BF 08 00 D4  LDA $D40008,X [$D4:0378]  ;; load accumulator from $D40008+X (read the right half)

$C0/CC4D: C2 20        REP #$20                  ;; set to 16 bit accumulator mode
$C0/CC4F: 85 B1        STA $B1 [$00:13B1]        ;; store accumulator to $B1 (make a copy of what we just read)
$C0/CC51: 4A           LSR A                     ;; shift bits in accumulator 'A' right by 1 (also has the effect of 										dividing the number by 2)
;; store A to memory (lower plane)
$C0/CC52: E2 20        SEP #$20                  ;; set to 8 bit accumulator mode
$C0/CC54: 99 B4 A4     STA $A4B4,Y [$7F:A4B4]    ;; store A to $7FA4B4 (its just memory) (store low byte of A)
$C0/CC57: EB           XBA                       ;; swap low and high bytes of accumulator
$C0/CC58: 99 94 A4     STA $A494,Y [$7F:A494]    ;; store A to $7FA594 (store what used to be the high byte of A)
$C0/CC5B: EB           XBA                       ;; swap low and high bytes of accumulator (back to normal)

;; this "adds" the original bits to the shifted set of bits
;; most likely this adds a shadow effect
$C0/CC5C: C2 20        REP #$20                  ;; set to 16 bit accumulator mode
$C0/CC5E: 05 B1        ORA $B1 [$00:13B1]        ;; OR accumulator with memory at $B1
$C0/CC60: 4A           LSR A                     ;; Shift Right accumulator/memory..(divide A by 2)
$C0/CC61: 05 B1        ORA $B1 [$00:13B1]        ;; OR accumulator with memory at $B1

;; again, store A to memory (upper plane)
$C0/CC63: E2 20        SEP #$20                  ;; set to 8 bit accumulator mode
$C0/CC65: 99 B5 A4     STA $A4B5,Y [$7F:A4B5]    ;; store Y to $A4B5
$C0/CC68: EB           XBA                       ;; exchange a & b
$C0/CC69: 99 95 A4     STA $A495,Y [$7F:A495]    ;; store Y to $A4B5

$C0/CC6C: C8           INY                       ;; y++
$C0/CC6D: C8           INY                       ;; y++ (add 2 to y to go to next row, 
									because each line is 2 bytes..1 per plane)
$C0/CC6E: E8           INX                       ;; x++ (increment the reading position)
$C0/CC6F: C0 10 00     CPY #$0010                ;; compare Y with $0010 (the tile is 0x10 bytes)
$C0/CC72: D0 0A        BNE $0A [$CC7E]           ;; branch to $cc7e if Y <> 0x10 
									(loop back if all bytes havent been copied)

;; if Y = 0x10 then (if its got through the first row of tiles)
;; X = X + 0x78 (move reading position to next row)
$C0/CC74: C2 20        REP #$20                  ;; set to 16 bit accumulator mode
$C0/CC76: 8A           TXA                       ;; transfer X to accumulator
$C0/CC77: 18           CLC                       ;; Clear the carry flag (always done with addition)
$C0/CC78: 69 78 00     ADC #$0078                ;; Add with carry: A = A + 0x0078 (A is being used as a temp variable)
$C0/CC7B: AA           TAX                       ;; transfer accumulator to X
$C0/CC7C: E2 20        SEP #$20                  ;; set to 8 bit accumulator mode

$C0/CC7E: C0 1E 00     CPY #$001E                ;; Compare Y with #$001E (check if the entire letter is done)
$C0/CC81: D0 C1        BNE $C1 [$CC44]           ;; branch to $CC44 if Y <> 0x1E (go back to top of loop if not)

;; if Y = 0x1E then (if the letter was completely copied)
$C0/CC83: A2 00 00     LDX #$0000                ;; Load X from #$0000
$C0/CC86: A0 00 00     LDY #$0000                ;; Load Y from #$0000

;; copy the higher plane onto the lower plane (this just changes the color)
$C0/CC89: BD 94 A4     LDA $A494,X [$7F:A494]    ;; Load A from $7FA494+X
$C0/CC8C: 19 93 A4     ORA $A493,Y [$7F:A493]    ;; OR A with $7FA493+Y
$C0/CC8F: 99 93 A4     STA $A493,Y [$7F:A493]    ;; Store A to $A493+Y
$C0/CC92: BD 94 A4     LDA $A494,X [$7F:A494]    ;; Load A from $7FA494+X
$C0/CC95: 19 97 A4     ORA $A497,Y [$7F:A497]    ;; OR A with $7FA497+Y
$C0/CC98: 99 97 A4     STA $A497,Y [$7F:A497]    ;; Store A to $7FA497+Y
$C0/CC9B: E8           INX                       ;; x++
$C0/CC9C: E8           INX                       ;; x++
$C0/CC9D: C8           INY                       ;; y++
$C0/CC9E: C8           INY                       ;; y++
$C0/CC9F: E0 3A 00     CPX #$003A                ;; compare X with #$003A
$C0/CCA2: D0 E5        BNE $E5 [$CC89]           ;; branch to $CC89 if X <> 0x3A (go back to top of loop)

;; we're done!
$C0/CCA4: 60           RTS                       ;; return from subroutine (end of routine)

Enjoy

Kammedo

http://nesdev.com/bbs/viewtopic.php?t=141&sid=edcf342526c3af8033bcca104a9aae36

Snowbro released a lot of source code earlier this year. Wonderful examples. :slight_smile:

wow sweet, cool stuff here, lots to read. especially in that 8 page forum thread…good god.