I'm trying to learn how to program for the PC Engine, I decided that I want to see the underlying code instead of using libraries + C translator... I don't have anything against HuC, actually it's great and easy, but since I've played around with NESASM a little bit I felt that I really wanted to learn to program in Assembler language.
But I need some help... I think I managed to figure out startup but I have some questions:
1- In the NES you had a specific memory space to upload characters (or it would be a ROM)... where is it on the PCE? I'm using $4000 VRAM address as in the MagicKit docs, but how does the PCE knows that the character data is there? Which leads to the second question, which I'm sure it is part of the first one.
2- The "BAT" doesn't store a simple index number like the NES, but the actual VRAM address + palette, right? Am I pointing to the first character (resident on $4000 onwards) by writing the value $0200 on VRAM address $0000? ($0200 * $20 = $4000).
3- Is there a debug friendly PCE emulator? I really loved FCEUXD SP and how you could see visually the nametables and characters uploaded into the PPU... is there something like it to see a visual representation of what data the PCE video processor chip is holding?
4- Now I'm going to be a moron and post my code... yes I know that asking to be spoonfed with solutions on a forum is bad but if I didn't get my issues covered with my first two questions you guys could help me... currently when I boot my compiled code into ootake it shows some dots plastered all over screen (as if I didn't upload the tiles correctly or as if I didn't write the character tile map in a recognisable format) when the intent was to show a character at 0,0 of the background.
;Sample Program
.include "instructions.asm"
.ZP ;Zero Page Data
Generic_Ptr .ds 2
.BSS ;RAM area.
Hi_Score .ds 2
Score_P1 .ds 2
Score_P2 .ds 2
.DATA
.bank 1
.org $4000
;Insert font here.
Ffont:
.incchr "Grafx/Stencil.PCX"
Fpal:
.incpal "Grafx/Stencil.PCX"
.CODE ;Start of ROM data.
.bank 0
.org $E000
BREAK:
RTI
VDC:
RTI
TIMER:
ACK ;STA $1403 macro.
RTI
NMI:
RTI
RESET:
LDA #$FF
TAM #0 ;Map I/O at bank 0
LDA #$F8
TAM #1 ;Map RAM at bank 1
LDA #$01
TAM #2 ;Map ROM bank 1 at bank 2
JSR LOADTXT; Loads Font into VRAM
; Also, this same subroutine writes a character at 0,0
; At least is supposed to.
.1
JMP .1
LOADTXT:
LDA #$09
STA $0000
LDA #%00000101
STA $0003
LDA #$00
STA $0000
LDA #$00
STA $0002
STA $0003
LDA #$02
STA $0000 ;Register #2 = VRAM read/write register
LDA #$40
STA $0002
LDA #$02
STA $0003 ;Write %0000 0010 0000 0000 to VRAM address $0000
;(Sets tile 0,0 to the character at $4000?)
LDA #$0F
STA $0000 ;Register #$0F = DMA Control Register
LDA #$00
STA $0002
STA $0003 ;No DSR DMA, Increment destination/source, no interrupts
LDA #$10 ;Register #$10 = DMA Source Address
STA $0000
LDA #LOW(Ffont); + 32
STA $0002
LDA #HIGH(Ffont); + 32
STA $0003 ;Set Source Address = Font address in ROM.
LDA #$11 ;Register #$11 = DMA Destination
STA $0000
LDA #$00
STA $0002
LDA #$40
STA $0003 ;Transfer font to VRAM $4000
;
LDA #$12 ;Register @#12 = DMA Length Register
STA $0000
LDA #$00
STA $0002
LDA #$08
STA $0003 ;Set block size to #$800 or 64 tiles
;Start transfer! (???)
LDX #$00
STX $0402
STX $0403 ;Choose color 0
LDA #$00
STA $0404
STA $0405 ;write some random color and change the BG to other than white
LDA #$05
STA $0000
LDA #%10100000
STA $0002 ;Turns on BG rendering...
RTS
.org $FFF6
.dw BREAK
.dw VDC
.dw TIMER
.dw NMI
.dw RESET