~rabbits/famicom-cookbook

8af89ce5c781728e0b3d882d663f0516765d382a — Devine Lu Linvega 3 years ago fb0b856 master
*
20 files changed, 276 insertions(+), 542 deletions(-)

D examples/background-partial/build.sh
D examples/background-partial/src/cart.asm
D examples/background-partial/src/head.asm
D examples/background-partial/src/main.asm
D examples/background-partial/src/sprite.chr
D examples/background-partial/src/tables.asm
D examples/background-partial/src/vectors.asm
M examples/build.sh
M examples/cart.nes
A examples/controls-debugger.asm
D examples/controls-debugger/build.sh
D examples/controls-debugger/debug.lua
D examples/controls-debugger/src/cart.asm
D examples/controls-debugger/src/head.asm
D examples/controls-debugger/src/main.asm
D examples/controls-debugger/src/sprite.chr
D examples/controls-debugger/src/tables.asm
D examples/controls-debugger/src/vectors.asm
R examples/{animation-follow.asm => controls-follow.asm}
A examples/debug.lua
D examples/background-partial/build.sh => examples/background-partial/build.sh +0 -12
@@ 1,12 0,0 @@
#!/bin/bash

# Remove old
rm cart.nes

# Build

../../assembler/asm6 src/cart.asm cart.nes

# Run

fceux cart.nes
\ No newline at end of file

D examples/background-partial/src/cart.asm => examples/background-partial/src/cart.asm +0 -9
@@ 1,9 0,0 @@
include "src/head.asm"
    
include "src/main.asm"

include "src/tables.asm"

include "src/vectors.asm"

    .incbin "src/sprite.chr"

D examples/background-partial/src/head.asm => examples/background-partial/src/head.asm +0 -77
@@ 1,77 0,0 @@
;;;;;;;;;;;;;;;;;;;;;;;
;;;   iNES HEADER   ;;;
;;;;;;;;;;;;;;;;;;;;;;;

  .db  "NES", $1a     ;identification of the iNES header
  .db  PRG_COUNT      ;number of 16KB PRG-ROM pages
  .db  $01            ;number of 8KB CHR-ROM pages
  .db  $70|MIRRORING  ;mapper 7
  .dsb $09, $00       ;clear the remaining bytes

  .fillvalue $FF      ; Sets all unused space in rom to value $FF

;;;;;;;;;;;;;;;;;;;;;
;;;   VARIABLES   ;;;
;;;;;;;;;;;;;;;;;;;;;

  .enum $0000 ; Zero Page variables

tile_index .dsb 1

  .ende

;;;;;;;;;;;;;;;;;;;;;
;;;   CONSTANTS   ;;;
;;;;;;;;;;;;;;;;;;;;;

PRG_COUNT       = 1       ;1 = 16KB, 2 = 32KB
MIRRORING       = %0001

PPU_Control     .equ $2000
PPU_Mask        .equ $2001
PPU_Status      .equ $2002
PPU_Scroll      .equ $2005
PPU_Address     .equ $2006
PPU_Data        .equ $2007

spriteRAM       .equ $0200

  .org $C000
    
;;;;;;;;;;;;;;;;;
;;;   RESET   ;;;
;;;;;;;;;;;;;;;;;

RESET:
  SEI          ; disable IRQs
  CLD          ; disable decimal mode
  LDX #$40
  STX $4017    ; disable APU frame IRQ
  LDX #$FF
  TXS          ; Set up stack
  INX          ; now X = 0
  STX $2000    ; disable NMI
  STX $2001    ; disable rendering
  STX $4010    ; disable DMC IRQs

Vblankwait1:       ; First wait for vblank to make sure PPU is ready
  BIT $2002
  BPL Vblankwait1

Clrmem:
  LDA #$00
  STA $0000, x
  STA $0100, x
  STA $0300, x
  STA $0400, x
  STA $0500, x
  STA $0600, x
  STA $0700, x
  LDA #$FE
  STA $0200, x    ;move all sprites off screen
  INX
  BNE Clrmem
   
Vblankwait2:      ; Second wait for vblank, PPU is ready after this
  BIT $2002
  BPL Vblankwait2
\ No newline at end of file

D examples/background-partial/src/main.asm => examples/background-partial/src/main.asm +0 -93
@@ 1,93 0,0 @@
  JSR LoadBackground
  JSR LoadPalettes
  JSR LoadAttributes

EnableSprites:
  LDA #%10010000   ; enable NMI, sprites from Pattern Table 0, background from Pattern Table 1
  STA $2000
  LDA #%00011110   ; enable sprites, enable background, no clipping on left side
  STA $2001
  
  LDA #$00         ; No background scrolling
  STA $2006
  STA $2006
  STA $2005
  STA $2005

Forever:
  JMP Forever     ;jump back to Forever, infinite loop

LoadBackground:
  LDA $2000 ; read PPU status to reset the high/low latch
  LDA #$20
  STA $2006 ; write the high byte of $2000 address
  LDA #$e4
  STA $2006 ; write the low byte of $2000 address
  LDX #$00
  LDY #$00
  JSR LoadCardRow
  RTS

LoadCardRow:
  LDA card, x        ; load data from address (sprites +  x)
  STA $2007                ; X = X + 1
  INX
  INC tile_index
  LDA tile_index
  CMP #$06
  BNE LoadCardRowContinue
  JSR row_end
LoadCardRowContinue:
  CPX #$3f              ; Compare X to hex $20, decimal 32
  BNE LoadCardRow
  RTS

row_end:
  LDA #$00
  STA pos_x
  LDA $2000 ; read PPU status to reset the high/low latch
  LDA cardpos_lb, y
  STA $2006 ; write the high byte of $2000 address
  LDA cardpos_hb, y
  STA $2006 ; write the low byte of $2000 address
  INY
  RTS

LoadPalettes:
  LDA $2002
  LDA #$3F
  STA $2006
  LDA #$00
  STA $2006

  LDX #$00
LoadPalettesLoop:
  LDA palettes, x
  STA $2007
  INX
  CPX #$20
  BNE LoadPalettesLoop
  RTS

LoadAttributes:
  LDA $2002
  LDA #$23
  STA $2006
  LDA #$C0
  STA $2006
  LDX #$00
LoadAttributesLoop:
  LDA attributes, x
  STA $2007
  INX
  CPX #$40
  BNE LoadAttributesLoop
  RTS

NMI:
  LDA #$00
  STA $2003       ; set the low byte (00) of the RAM address
  LDA #$02
  STA $4014       ; set the high byte (02) of the RAM address, start the transfer
  
  RTI             ; return from interrupt
\ No newline at end of file

D examples/background-partial/src/sprite.chr => examples/background-partial/src/sprite.chr +0 -0
D examples/background-partial/src/tables.asm => examples/background-partial/src/tables.asm +0 -36
@@ 1,36 0,0 @@
;;;;;;;;;;;;;;;;;;
;;;   TABLES   ;;;
;;;;;;;;;;;;;;;;;;

  .org $E000

attributes:
  .db %00000000, %00000000, %00000000, %00000000, %00000000, %00000000, %00000000, %00000000
  .db %00000000, %00000000, %00000000, %00000000, %00000000, %00000000, %00000000, %00000000
  .db %00000000, %00000000, %00000000, %00000000, %00000000, %00000000, %00000000, %00000000
  .db %00000000, %00000000, %00000000, %00000000, %00000000, %00000000, %00000000, %00000000
  .db %00000000, %00000000, %00000000, %00000000, %00000000, %00000000, %00000000, %00000000
  .db %00000000, %00000000, %00000000, %00000000, %00000000, %00000000, %00000000, %00000000
  .db %00000000, %00000000, %00000000, %00000000, %00000000, %00000000, %00000000, %00000000
  .db %00000000, %00000000, %00000000, %00000000, %00000000, %00000000, %00000000, %00000000

palettes:
  .db $0F,$23,$3B,$30, $3B,$3B,$0F,$0F, $0F,$3B,$0F,$0F, $0F,$3B,$0F,$0F
  .db $0F,$10,$17,$07, $0F,$3B,$0F,$0F, $0F,$0F,$0F,$0F, $0F,$0F,$0F,$0F

card:
  .db $01,$02,$02,$02,$02,$03
  .db $05,$0c,$06,$06,$06,$07
  .db $05,$0d,$06,$06,$06,$07
  .db $05,$06,$0e,$0e,$06,$07
  .db $05,$06,$0e,$0e,$06,$07
  .db $05,$06,$0e,$0e,$06,$07
  .db $05,$06,$06,$06,$0d,$07
  .db $05,$06,$06,$06,$0c,$07
  .db $09,$0a,$0a,$0a,$0a,$0b

cardpos_lb:
  .db $21,$21,$21,$21,$21,$21,$21,$21,$22

cardpos_hb:
  .db $04,$24,$44,$64,$84,$a4,$c4,$e4,$04
\ No newline at end of file

D examples/background-partial/src/vectors.asm => examples/background-partial/src/vectors.asm +0 -9
@@ 1,9 0,0 @@
;;;;;;;;;;;;;;;;;;;
;;;   VECTORS   ;;;
;;;;;;;;;;;;;;;;;;;

  .pad $FFFA

  .dw NMI
  .dw RESET
  .dw 0
\ No newline at end of file

M examples/build.sh => examples/build.sh +2 -2
@@ 1,6 1,6 @@
#!/bin/bash

target=animation-sine.asm
target=controls-debugger.asm

# Remove old cart
if test -f "cart.nes"; then


@@ 36,4 36,4 @@ echo "Assembling new cart."
../tools/asm6 $target cart.nes

# Run
fceux cart.nes
fceux cart.nes --loadlua debug.lua

M examples/cart.nes => examples/cart.nes +0 -0
A examples/controls-debugger.asm => examples/controls-debugger.asm +255 -0
@@ 0,0 1,255 @@

;; iNES header

	.db "NES", $1a ; identification of the iNES header
	.db 1 ; number of 16KB PRG-ROM pages
	.db $01 ; number of 8KB CHR-ROM pages
	.db $00 ; NROM
	.dsb $09,$00 ; clear the remaining bytes
	.fillvalue $FF ; Sets all unused space in rom to value $FF

;; variables

	.enum $0000 ; Zero Page variables
	pos_x                   .dsb 1
	pos_y                   .dsb 1
	tile_x                  .dsb 1
	tile_y                  .dsb 1
	.ende 

;; constants

	PPU_CONTROL             .equ $2000 
	PPU_MASK                .equ $2001 
	PPU_STATUS              .equ $2002 
	PPU_SCROLL              .equ $2005 
	PPU_ADDRESS             .equ $2006 
	PPU_DATA                .equ $2007 
	SPRITERAM               .equ $0200 
	.org $C000

;; RESET

RESET: 
	SEI                                ; disable IRQs
	CLD                                ; disable decimal mode
	LDX #$40
	STX $4017                          ; disable APU frame IRQ
	LDX #$FF
	TXS                                ; Set up stack
	INX                                ; now X = 0
	STX $2000                          ; disable NMI
	STX $2001                          ; disable rendering
	STX $4010                          ; disable DMC IRQs

Vblankwait1: ; First wait for vblank to make sure PPU is ready
	BIT $2002
	BPL Vblankwait1

Clrmem: 
	LDA #$00
	STA $0000, x
	STA $0100, x
	STA $0300, x
	STA $0400, x
	STA $0500, x
	STA $0600, x
	STA $0700, x
	LDA #$FE
	STA $0200, x                       ;move all sprites off screen
	INX 
	BNE Clrmem

Vblankwait2: ; Second wait for vblank, PPU is ready after this
	BIT $2002
	BPL Vblankwait2
	; origins
	LDA #$88
	STA pos_x
	LDA #$88
	STA pos_y

LoadPalettes: 
	LDA $2002                          ; read PPU status to reset the high/low latch
	LDA #$3F
	STA $2006                          ; write the high byte of $3F00 address
	LDA #$00
	STA $2006                          ; write the low byte of $3F00 address
	LDX #$00                           ; start out at 0

LoadPalettesLoop: 
	LDA Palette, x                     ; load data from address (palette + the value in x)
	STA $2007                          ; write to PPU
	INX                                ; X = X + 1
	CPX #$20                           ; Compare X to hex $10, decimal 16 - copying 16 bytes = 4 sprites
	BNE LoadPalettesLoop

CreateSprite: 
	LDA pos_y
	STA $0200                          ; set tile.y pos
	LDA #$05
	STA $0201                          ; set tile.id
	LDA #$00
	STA $0202                          ; set tile.attribute
	LDA pos_x
	STA $0203                          ; set tile.x pos

CreateGui: 

CreateGuiX: 
	LDA #$20
	STA $0204                          ; set tile.y pos
	LDA #$21
	STA $0205                          ; set tile.id
	LDA #$00
	STA $0206                          ; set tile.attribute
	LDA #$20
	STA $0207                          ; set tile.x pos

CreateGuiY: 
	LDA #$20
	STA $0208                          ; set tile.y pos
	LDA #$21
	STA $0209                          ; set tile.id
	LDA #$00
	STA $020a                          ; set tile.attribute
	LDA #$28
	STA $020b                          ; set tile.x pos
	LDA #%10000000                     ; enable NMI, sprites from Pattern Table 1
	STA $2000
	LDA #%00010000                     ; enable sprites
	STA $2001

Forever: 
	JMP Forever                        ;jump back to Forever, infinite loop

NMI: 
	LDA #$00
	STA $2003                          ; set the low byte (00) of the RAM address
	LDA #$02
	STA $4014                          ; set the high byte (02) of the RAM address, start the transfer

LatchController: 
	LDA #$01
	STA $4016
	LDA #$00
	STA $4016                          ; tell both the controllers to latch buttons

ReadA: 
	LDA $4016
	AND #%00000001                     ; only look at bit 0
	BEQ ReadADone
	LDA #$06                           ; sprite tile
	STA $0201

ReadADone: ; handling this button is done

ReadB: 
	LDA $4016
	AND #%00000001                     ; only look at bit 0
	BEQ ReadBDone
	LDA #$06                           ; sprite tile
	STA $0201

ReadBDone: ; handling this button is done

ReadSel: 
	LDA $4016
	AND #%00000001                     ; only look at bit 0
	BEQ ReadSelDone
	LDA #$06                           ; sprite tile
	STA $0201

ReadSelDone: ; handling this button is done

ReadStart: 
	LDA $4016
	AND #%00000001                     ; only look at bit 0
	BEQ ReadStartDone
	LDA #$06                           ; sprite tile
	STA $0201

ReadStartDone: ; handling this button is done

ReadUp: 
	LDA $4016
	AND #%00000001                     ; only look at bit 0
	BEQ ReadUpDone
	DEC pos_y
	LDA #$01                           ; sprite tile
	STA $0201
	JSR Update

ReadUpDone: ; handling this button is done

ReadDown: 
	LDA $4016
	AND #%00000001                     ; only look at bit 0
	BEQ ReadDownDone
	INC pos_y
	LDA #$02                           ; sprite tile
	STA $0201
	JSR Update

ReadDownDone: ; handling this button is done

ReadLeft: 
	LDA $4016
	AND #%00000001                     ; only look at bit 0
	BEQ ReadLeftDone
	DEC pos_x
	LDA #$03                           ; sprite tile
	STA $0201
	JSR Update

ReadLeftDone: ; handling this button is done

ReadRight: 
	LDA $4016
	AND #%00000001                     ; only look at bit 0
	BEQ ReadRightDone
	INC pos_x
	LDA #$04                           ; sprite tile
	STA $0201
	JSR Update

ReadRightDone: ; handling this button is done
	RTI                                ; return from interrupt

Update: 
	; move X
	LDA pos_x                          ; load pos x
	STA $0203                          ; set x pos
	STA tile_x
	LSR tile_x
	LSR tile_x
	LSR tile_x
	LSR tile_x
	LDA tile_x
	ADC #$20
	STA $0205
	; move y
	LDA pos_y                          ; load pos y
	STA $0200                          ; set y pos
	STA tile_y
	LSR tile_y
	LSR tile_y
	LSR tile_y
	LSR tile_y
	LDA tile_y
	ADC #$20
	STA $0209
	RTS 
	.align $100

Palette: 
	.db $0F,$31,$32,$33,$34,$35,$36,$37,$38,$39,$3A,$3B,$3C,$3D,$3E,$0F
	.db $0F,$3B,$15,$0F,$0F,$02,$0F,$0F,$0F,$1C,$15,$14,$31,$02,$38,$3C

;; VECTORS

	.pad $FFFA
	.dw NMI
	.dw RESET
	.dw 0
	.incbin "sprite.chr"

D examples/controls-debugger/build.sh => examples/controls-debugger/build.sh +0 -12
@@ 1,12 0,0 @@
#!/bin/bash

# Remove old
rm cart.nes

# Build

../../assembler/asm6 src/cart.asm cart.nes

# Run

fceux cart.nes
\ No newline at end of file

D examples/controls-debugger/debug.lua => examples/controls-debugger/debug.lua +0 -11
@@ 1,11 0,0 @@
emu.speedmode("normal") -- Set the speed of the emulator

-- Declare and set variables or functions if needed

while true do

  -- Execute instructions for FCEUX

  emu.frameadvance() -- This essentially tells FCEUX to keep running
  gui.text(20,20,string.format("x:%x y:%x", memory.readbyte(0x0000) * 256, memory.readbyte(0x0001) * 256));
end
\ No newline at end of file

D examples/controls-debugger/src/cart.asm => examples/controls-debugger/src/cart.asm +0 -9
@@ 1,9 0,0 @@
include "src/head.asm"
    
include "src/main.asm"

include "src/tables.asm"

include "src/vectors.asm"

    .incbin "src/sprite.chr"

D examples/controls-debugger/src/head.asm => examples/controls-debugger/src/head.asm +0 -85
@@ 1,85 0,0 @@
;;;;;;;;;;;;;;;;;;;;;;;
;;;   iNES HEADER   ;;;
;;;;;;;;;;;;;;;;;;;;;;;

    .db  "NES", $1a     ;identification of the iNES header
    .db  PRG_COUNT      ;number of 16KB PRG-ROM pages
    .db  $01            ;number of 8KB CHR-ROM pages
    .db  $70|MIRRORING  ;mapper 7
    .dsb $09, $00       ;clear the remaining bytes

    .fillvalue $FF      ; Sets all unused space in rom to value $FF

;;;;;;;;;;;;;;;;;;;;;
;;;   VARIABLES   ;;;
;;;;;;;;;;;;;;;;;;;;;

    .enum $0000 ; Zero Page variables

pos_x            .dsb 1
pos_y            .dsb 1
tile_x           .dsb 1
tile_y           .dsb 1

    .ende

    .enum $0400 ; Variables at $0400. Can start on any RAM page

sleeping        .dsb 1

    .ende

;;;;;;;;;;;;;;;;;;;;;
;;;   CONSTANTS   ;;;
;;;;;;;;;;;;;;;;;;;;;

PRG_COUNT       = 1       ;1 = 16KB, 2 = 32KB
MIRRORING       = %0001

PPU_Control     .equ $2000
PPU_Mask        .equ $2001
PPU_Status      .equ $2002
PPU_Scroll      .equ $2005
PPU_Address     .equ $2006
PPU_Data        .equ $2007

spriteRAM       .equ $0200
    .org $C000
    
;;;;;;;;;;;;;;;;;
;;;   RESET   ;;;
;;;;;;;;;;;;;;;;;

RESET:
  SEI          ; disable IRQs
  CLD          ; disable decimal mode
  LDX #$40
  STX $4017    ; disable APU frame IRQ
  LDX #$FF
  TXS          ; Set up stack
  INX          ; now X = 0
  STX $2000    ; disable NMI
  STX $2001    ; disable rendering
  STX $4010    ; disable DMC IRQs

Vblankwait1:       ; First wait for vblank to make sure PPU is ready
  BIT $2002
  BPL Vblankwait1

Clrmem:
  LDA #$00
  STA $0000, x
  STA $0100, x
  STA $0300, x
  STA $0400, x
  STA $0500, x
  STA $0600, x
  STA $0700, x
  LDA #$FE
  STA $0200, x    ;move all sprites off screen
  INX
  BNE Clrmem
   
Vblankwait2:      ; Second wait for vblank, PPU is ready after this
  BIT $2002
  BPL Vblankwait2
\ No newline at end of file

D examples/controls-debugger/src/main.asm => examples/controls-debugger/src/main.asm +0 -169
@@ 1,169 0,0 @@
; origins
  LDA #$88
  STA pos_x
  LDA #$88
  STA pos_y

LoadPalettes:
  LDA $2002             ; read PPU status to reset the high/low latch
  LDA #$3F
  STA $2006             ; write the high byte of $3F00 address
  LDA #$00
  STA $2006             ; write the low byte of $3F00 address
  LDX #$00              ; start out at 0

LoadPalettesLoop:
  LDA palette, x        ; load data from address (palette + the value in x)
  STA $2007             ; write to PPU
  INX                   ; X = X + 1
  CPX #$20              ; Compare X to hex $10, decimal 16 - copying 16 bytes = 4 sprites
  BNE LoadPalettesLoop  

CreateSprite:
  LDA pos_y
  STA $0200        ; set tile.y pos
  LDA #$05
  STA $0201        ; set tile.id
  LDA #$00
  STA $0202        ; set tile.attribute
  LDA pos_x
  STA $0203        ; set tile.x pos

CreateGui:
CreateGuiX:
  LDA #$20
  STA $0204        ; set tile.y pos
  LDA #$21
  STA $0205        ; set tile.id
  LDA #$00
  STA $0206        ; set tile.attribute
  LDA #$20
  STA $0207        ; set tile.x pos
CreateGuiY:
  LDA #$20
  STA $0208        ; set tile.y pos
  LDA #$21
  STA $0209        ; set tile.id
  LDA #$00
  STA $020a        ; set tile.attribute
  LDA #$28
  STA $020b        ; set tile.x pos

  LDA #%10000000   ; enable NMI, sprites from Pattern Table 1
  STA $2000
  LDA #%00010000   ; enable sprites
  STA $2001

Forever:
  JMP Forever     ;jump back to Forever, infinite loop

NMI:
  LDA #$00
  STA $2003       ; set the low byte (00) of the RAM address
  LDA #$02
  STA $4014       ; set the high byte (02) of the RAM address, start the transfer

LatchController:
  LDA #$01
  STA $4016
  LDA #$00
  STA $4016       ; tell both the controllers to latch buttons

ReadA: 
  LDA $4016
  AND #%00000001  ; only look at bit 0
  BEQ ReadADone
  LDA #$06        ; sprite tile
  STA $0201
ReadADone:        ; handling this button is done
  
ReadB: 
  LDA $4016
  AND #%00000001  ; only look at bit 0
  BEQ ReadBDone
  LDA #$06        ; sprite tile
  STA $0201
ReadBDone:        ; handling this button is done

ReadSel: 
  LDA $4016
  AND #%00000001  ; only look at bit 0
  BEQ ReadSelDone 
  LDA #$06        ; sprite tile
  STA $0201
ReadSelDone:        ; handling this button is done

ReadStart: 
  LDA $4016
  AND #%00000001  ; only look at bit 0
  BEQ ReadStartDone 
  LDA #$06        ; sprite tile
  STA $0201
ReadStartDone:        ; handling this button is done

ReadUp: 
  LDA $4016
  AND #%00000001  ; only look at bit 0
  BEQ ReadUpDone 
  DEC pos_y
  LDA #$01        ; sprite tile
  STA $0201
  JSR Update
ReadUpDone:        ; handling this button is done

ReadDown: 
  LDA $4016
  AND #%00000001  ; only look at bit 0
  BEQ ReadDownDone 
  INC pos_y
  LDA #$02        ; sprite tile
  STA $0201
  JSR Update
ReadDownDone:        ; handling this button is done

ReadLeft: 
  LDA $4016
  AND #%00000001  ; only look at bit 0
  BEQ ReadLeftDone 
  DEC pos_x
  LDA #$03        ; sprite tile
  STA $0201
  JSR Update
ReadLeftDone:        ; handling this button is done

ReadRight: 
  LDA $4016
  AND #%00000001  ; only look at bit 0
  BEQ ReadRightDone 
  INC pos_x
  LDA #$04        ; sprite tile
  STA $0201
  JSR Update
ReadRightDone:        ; handling this button is done
  
  RTI             ; return from interrupt

Update:
  ; move X
  LDA pos_x ; load pos x
  STA $0203 ; set x pos
  STA tile_x
  LSR tile_x
  LSR tile_x
  LSR tile_x
  LSR tile_x
  LDA tile_x
  ADC #$20
  STA $0205
  ; move y
  LDA pos_y ; load pos y
  STA $0200 ; set y pos
  STA tile_y
  LSR tile_y
  LSR tile_y
  LSR tile_y
  LSR tile_y
  LDA tile_y
  ADC #$20
  STA $0209
  RTS
\ No newline at end of file

D examples/controls-debugger/src/sprite.chr => examples/controls-debugger/src/sprite.chr +0 -0
D examples/controls-debugger/src/tables.asm => examples/controls-debugger/src/tables.asm +0 -9
@@ 1,9 0,0 @@
;;;;;;;;;;;;;;;;;;
;;;   TABLES   ;;;
;;;;;;;;;;;;;;;;;;

  .align $100
    
palette:
  .db $0F,$31,$32,$33,$34,$35,$36,$37,$38,$39,$3A,$3B,$3C,$3D,$3E,$0F
  .db $0F,$3B,$15,$0F,$0F,$02,$0F,$0F,$0F,$1C,$15,$14,$31,$02,$38,$3C
\ No newline at end of file

D examples/controls-debugger/src/vectors.asm => examples/controls-debugger/src/vectors.asm +0 -9
@@ 1,9 0,0 @@
;;;;;;;;;;;;;;;;;;;
;;;   VECTORS   ;;;
;;;;;;;;;;;;;;;;;;;

  .pad $FFFA

  .dw NMI
  .dw RESET
  .dw 0
\ No newline at end of file

R examples/animation-follow.asm => examples/controls-follow.asm +0 -0
A examples/debug.lua => examples/debug.lua +19 -0
@@ 0,0 1,19 @@
print("Added debugger!")

emu.speedmode("normal") -- Set the speed of the emulator

function printaddr(addr)
  res = string.format("%02x", memory.readbyte(addr) * 256):sub(1, -3)
  len = string.len(res)
  if len == 0 then return "00" elseif len <= 1 then return "0"..res else return res end
end

while true do
  for x=0,15 do 
    for y=0,3 do 
      id = x + (y * 16)
      gui.text((x * 15) + 10, (y * 15) + 10, printaddr(id))
    end
  end
  emu.frameadvance() 
end
\ No newline at end of file