DylanSpeiser / Java-6502-Emulator

An emulator for Ben Eater's 65C02 computer written in Java.
47 stars 14 forks source link

Problem loading file to ROM and RAM #10

Closed luc0x closed 1 year ago

luc0x commented 1 year ago

When I try to load a file to ROM and RAM, I get this error: Exception in thread "AWT-EventQueue-0" java.lang.StringIndexOutOfBoundsException: Range [0, 960) out of bounds for length 24 at java.base/jdk.internal.util.Preconditions$1.apply(Preconditions.java:55) at java.base/jdk.internal.util.Preconditions$1.apply(Preconditions.java:52) at java.base/jdk.internal.util.Preconditions$4.apply(Preconditions.java:213) at java.base/jdk.internal.util.Preconditions$4.apply(Preconditions.java:210) at java.base/jdk.internal.util.Preconditions.outOfBounds(Preconditions.java:98) at java.base/jdk.internal.util.Preconditions.outOfBoundsCheckFromToIndex(Preconditions.java:112) at java.base/jdk.internal.util.Preconditions.checkFromToIndex(Preconditions.java:349) at java.base/java.lang.String.checkBoundsBeginEnd(String.java:4602) at java.base/java.lang.String.substring(String.java:2715) at DisplayPanel.actionPerformed(DisplayPanel.java:158) at java.desktop/javax.swing.Timer.fireActionPerformed(Timer.java:311) at java.desktop/javax.swing.Timer$DoPostEvent.run(Timer.java:243) at java.desktop/java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:318) at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:773) at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:720) at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:714) at java.base/java.security.AccessController.doPrivileged(AccessController.java:399) at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:86) at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:742) at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:203) at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:124) at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:113) at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:109) at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101) at java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:90) The code I want to load is this: ASM: start: lda #$ff ldy #$ff ldx #$ff Hex: A9 FF A0 FF A2 FF Thank you!

DylanSpeiser commented 1 year ago

Could you attach the .bin file you are trying to load?

luc0x commented 1 year ago

Github doesn't allow you to upload a .bin file directly to the thread, so I uploaded it to this repository: https://github.com/Luc-cr/ASM-6502-Test

DylanSpeiser commented 1 year ago

Ah. Like the actual ROM, the emulator needs a full 32kb file for either the ROM (or RAM). This is because the RESET, IRQ, and NMI vectors are at the very end of the address space, and the CPU needs to read from that location on startup/reset. Ben's videos go more into this. I'll add a handler for that case, with a more descriptive error.

luc0x commented 1 year ago

Ok, Thanks for helping me.