1
0
mirror of https://github.com/safiire/n65.git synced 2024-12-12 00:29:03 +00:00

Made error messages a bit better, error on mapper other than 0, fixed scrolling in demo

This commit is contained in:
Safiire 2015-02-23 00:24:57 -08:00
parent 2cf2680aaa
commit 337688b456
3 changed files with 21 additions and 45 deletions

View File

@ -93,10 +93,20 @@ module Assembler6502
STDERR.puts "Missing options try --help"
exit(1)
end
begin
Assembler6502::Assembler.from_file(input_file, options[:out_file])
rescue StandardError => error
STDERR.puts("Assemble Failed!")
STDERR.puts(error.class)
if error.message
STDERR.puts(error.message)
end
exit(1)
end
end
module_function :run
end
Assembler6502.run
Assembler6502.run

View File

@ -47,6 +47,7 @@ module Assembler6502
## Custom exceptions
class INESHeaderNotFound < StandardError; end
class MapperNotSupported < StandardError; end
####
@ -152,48 +153,6 @@ module Assembler6502
end
####
## After assembling the binary into the full 16-bit memory space
## we can now slice out the parts that should go into the binary ROM
## I am guessing the ROM size should be 1 bank of 16KB cartridge ROM
## plus the 16 byte iNES header. If the ROM is written into memory
## beginning at 0xC000, this should reach right up to the interrupt vectors
def assemble_old
virtual_memory = assemble_in_virtual_memory
## First we need to be sure we have an iNES header
fail(INESHeaderNotFound) if @ines_header.nil?
## Create memory to hold the ROM
nes_rom = MemorySpace.new(0x10 + 0x4000)
## First write the iNES header itself
nes_rom.write(0x0, @ines_header.emit_bytes)
## Write only one PROG section from 0xC000
start_address = 0xC000
length = 0x4000
prog_rom = virtual_memory.read(start_address, length)
write_start = 0x10
nes_rom.write(write_start, prog_rom)
## Now try writing one CHR-ROM section from 0x0000
start_address = 0x0000
length = 0x4000
char_rom = virtual_memory.read(start_address, length)
write_start = 0x10 + 0x4000
nes_rom.write(write_start, char_rom)
nes_rom.emit_bytes
#rom_size = 16 + (0xffff - 0xc000)
#nes_rom = MemorySpace.new(rom_size)
#nes_rom.write(0x0, virtual_memory.read(0x0, 0x10))
#nes_rom.write(0x10, virtual_memory.read(0xC000, 0x4000))
#nes_rom.emit_bytes
end
####
## New ROM assembly, this is so simplified, and needs to take banks into account
## This will happen once I fully understand mappers and banks.
@ -201,6 +160,9 @@ module Assembler6502
## Assemble into a virtual memory space
virtual_memory = assemble_in_virtual_memory
## First we need to be sure we have an iNES header
fail(MapperNotSupported, "Mapper #{@ines_header.mapper} not supported") if @ines_header.mapper != 0
## First we need to be sure we have an iNES header
fail(INESHeaderNotFound) if @ines_header.nil?

View File

@ -20,6 +20,7 @@
; *dx = $00 ; The speed delta x of the sprite
; *a = $01 ; Whether the A button is down
; *scroll = $02 ; The scroll amount
; *dy = $03 ; The speed delta y of the sprite
;
; *sprite = $200 ; Some sprite memory
; Actually I can probably do this with a .org and label pair
@ -116,7 +117,7 @@ init_sprites:
lda #$00
ldx #$00
sprite_clear1:
sta $0200, X ; $0200 = sprite
sta sprite, x
inx
bne sprite_clear1
@ -131,6 +132,9 @@ sprite_clear1:
; Set initial value of dx
lda #$01
sta $00 ; dx = $00
; Set initial value of dy
lda #$70
sta $03 ; dy = $03
rts
; Load palette into $3F00