Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
146 changes: 146 additions & 0 deletions presets/apple2/applesinglebin.a
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
; --------------------------------------------------
; Example showing how to create an AppleSingle binary
; header and program that is automatically loaded
; into the desired PGM_START memory address.
; --------------------------------------------------

processor 6502

; --------------------------------------------------
; Set PGM_START to desired start of program execution
; - PGM_START must be less than $C000
; - PGM_START + SIZE must be less than $13000
; --------------------------------------------------
PGM_START equ $2000
PGM_LENGTH equ PGM_END - PGM_START

seg
org PGM_START - 58 ; Subtract 58 bytes for header

; --------------------------------------------------
; AppleSingle version 2 file header
; --------------------------------------------------
; - https://github.com/cc65/cc65/blob/master/libsrc/apple2/exehdr.s
; - https://nulib.com/library/FTN.e00001.htm
; - https://www.kreativekorp.com/miscpages/a2info/filetypes.shtml
__HEADER_BEGIN
.byte $00, $05, $16, $00 ; Magic number
.byte $00, $02, $00, $00 ; Version number

; Home File System - 16 bytes
; ProDOS
.byte $50,$72,$6F,$44,$4F,$53,$20,$20
.byte $20,$20,$20,$20,$20,$20,$20,$20

.byte 0, 2 ; Number of entries
.byte 0, 0, 0, 1 ; Entry ID 1 - Data Fork
.byte 0, 0, >__DATA_OFFSET, <__DATA_OFFSET ; Offset
.byte 0, 0, >PGM_LENGTH, <PGM_LENGTH ; Length

.byte 0, 0, 0, 11 ; Entry ID 11 - ProDOS File Info
.byte 0, 0, >__PRODOS_OFFSET, <__PRODOS_OFFSET ; Offset
.byte 0, 0, >__PRODOS_LENGTH, <__PRODOS_LENGTH ; Length
__PRODOS_INFO
.byte 0, %11000011 ; Access - Destroy, Rename, Write, Read
.byte 0, 6 ; File Type - BIN
.byte 0, 0 ; Auxiliary Type high
.byte >PGM_START, <PGM_START ; Auxiliary Type low
__HEADER_END:

__DATA_OFFSET equ __HEADER_END - __HEADER_BEGIN
__PRODOS_LENGTH equ __HEADER_END - __PRODOS_INFO
__PRODOS_OFFSET equ __PRODOS_INFO - __HEADER_BEGIN

PGM_LENGTH equ PGM_END - PGM_START


; --------------------------------------------------
; ROM routines
; --------------------------------------------------
HOME equ $FC58


; --------------------------------------------------
; Start of program
; --------------------------------------------------
PGM_START

; --------------------------------------------------
; Clear screen
; --------------------------------------------------
jsr HOME

; --------------------------------------------------
; Print "PGM_START $" (11 chars) to $0400..$040a
; --------------------------------------------------
ldx #0
pfx_loop
lda prefix,x
ora #$80
sta $0400,x
inx
cpx #11
bne pfx_loop


; --------------------------------------------------
; Print origin in hex to $040b - $040e
; --------------------------------------------------

; High byte high nibble
lda #>PGM_START
lsr
lsr
lsr
lsr
tax
lda hexchar,x
ora #$80
sta $040b

; High byte low nibble
lda #>PGM_START
and #$0F
tax
lda hexchar,x
ora #$80
sta $040c

; Low byte high nibble
lda #<PGM_START
lsr
lsr
lsr
lsr
tax
lda hexchar,x
ora #$80
sta $040d

; Low byte low nibble
lda #<PGM_START
and #$0F
tax
lda hexchar,x
ora #$80
sta $040e

; --------------------------------------------------
; Endless loop (text stays on screen)
; --------------------------------------------------
done jmp done


; --------------------------------------------------
; Data
; --------------------------------------------------
prefix
.byte "PGM_START $"

hexchar
.byte "0123456789ABCDEF"



PGM_END
; Don't add instructions after this line
59 changes: 31 additions & 28 deletions presets/apple2/dos33bin.a
Original file line number Diff line number Diff line change
@@ -1,98 +1,98 @@
; --------------------------------------------------
; Example showing how to create a DOS 3.3 binary
; header and program that is automatically loaded
; into the desired ORIGIN memory address.
; into the desired PGM_START memory address.
; --------------------------------------------------

processor 6502

; --------------------------------------------------
; Desired origin
; - Origin must be less than $C000
; - Origin + size must be less than $13000
; - Origin must be $0803 or aligned to $xx00
; Set PGM_START to desired start of program execution
; - PGM_START must be less than $C000
; - PGM_START + SIZE must be less than $13000
; --------------------------------------------------
ORIGIN equ $2000
SIZE equ END_OF_PRORGAM-ORIGIN
PGM_START equ $2000
PGM_LENGTH equ PGM_END - PGM_START

seg
org PGM_START - 4 ; Subtract 4 bytes for header

; --------------------------------------------------
; DOS 3.3 binary header (4 bytes)
; --------------------------------------------------
org ORIGIN - 4 ; Subtract 4 ensures correct memory locations
word ORIGIN ; Origin (2 bytes)
word SIZE ; Size (2 bytes), must be length - 4
word PGM_START ; Program start address in memory (2 bytes)
word PGM_LENGTH ; Program length (2 bytes), must be file size - 4

; --------------------------------------------------
; ROM routines
; --------------------------------------------------
HOME equ $FC58


; --------------------------------------------------
; Origin and start of program
; Start of program
; --------------------------------------------------
org ORIGIN ; Starting address

PGM_START

start
; --------------------------------------------------
; Clear screen
; --------------------------------------------------
jsr HOME

; --------------------------------------------------
; Print "START $" (7 chars) to $0400..$0406
; Print "PGM_START $" (11 chars) to $0400..$040a
; --------------------------------------------------
ldx #0
pfx_loop
lda prefix,x
ora #$80
sta $0400,x
inx
cpx #7
cpx #11
bne pfx_loop


; --------------------------------------------------
; Print origin in hex to $0407 - $040A
; Print origin in hex to $040b - $040e
; --------------------------------------------------

; High byte high nibble
lda #>start
lda #>PGM_START
lsr
lsr
lsr
lsr
tax
lda hexchar,x
ora #$80
sta $0407
sta $040b

; High byte low nibble
lda #>start
lda #>PGM_START
and #$0F
tax
lda hexchar,x
ora #$80
sta $0408
sta $040c

; Low byte high nibble
lda #<start
lda #<PGM_START
lsr
lsr
lsr
lsr
tax
lda hexchar,x
ora #$80
sta $0409
sta $040d

; Low byte low nibble
lda #<start
lda #<PGM_START
and #$0F
tax
lda hexchar,x
ora #$80
sta $040A
sta $040e

; --------------------------------------------------
; Endless loop (text stays on screen)
Expand All @@ -104,9 +104,12 @@ done jmp done
; Data
; --------------------------------------------------
prefix
byte "START $"
.byte "PGM_START $"

hexchar
byte "0123456789ABCDEF"
.byte "0123456789ABCDEF"



END_OF_PRORGAM ; Don't add instructions after this line
PGM_END
; Don't add instructions after this line
6 changes: 3 additions & 3 deletions src/common/baseplatform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ export interface Platform {
getPresets?(): Preset[];
pause(): void;
resume(): void;
loadROM(title: string, rom: any); // TODO: Uint8Array
loadROM(title: string, rom: any, origin?: number); // TODO: Uint8Array
loadBIOS?(title: string, rom: Uint8Array);
getROMExtension?(rom: FileData): string;

Expand Down Expand Up @@ -869,8 +869,8 @@ export abstract class BaseMachinePlatform<T extends Machine> extends BaseDebugPl
}
}

loadROM(title, data) {
this.machine.loadROM(data, title);
loadROM(title, data, origin?: number) {
this.machine.loadROM(data, title, origin);
this.reset();
}

Expand Down
4 changes: 2 additions & 2 deletions src/common/devices.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export interface SampledAudioSource {
}

export interface AcceptsROM {
loadROM(data: Uint8Array, title?: string): void;
loadROM(data: Uint8Array, title?: string, origin?: number): void;
}

export interface AcceptsBIOS {
Expand Down Expand Up @@ -247,7 +247,7 @@ export abstract class BasicHeadlessMachine implements HasCPU, Bus, AcceptsROM, P
reset() {
this.cpu.reset();
}
loadROM(data: Uint8Array, title?: string): void {
loadROM(data: Uint8Array, title?: string, origin?: number): void {
if (!this.rom) this.rom = new Uint8Array(this.defaultROMSize);
if (data.length > this.rom.length)
throw new Error(`ROM too big: ${data.length} > ${this.rom.length}`);
Expand Down
1 change: 1 addition & 0 deletions src/common/workertypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ export interface WorkerOutputResult<T> {
params?: {}
segments?: Segment[]
debuginfo?: {} // optional info
origin?: number
}

export function isUnchanged(result: WorkerResult) : result is WorkerUnchangedResult {
Expand Down
2 changes: 1 addition & 1 deletion src/ide/ui.ts
Original file line number Diff line number Diff line change
Expand Up @@ -931,7 +931,7 @@ async function setCompileOutput(data: WorkerResult) {
try {
clearBreakpoint(); // so we can replace memory (TODO: change toolbar btn)
_resetRecording();
await platform.loadROM(getCurrentPresetTitle(), rom);
await platform.loadROM(getCurrentPresetTitle(), rom, data.origin);
current_output = rom;
if (!userPaused) _resume();
writeOutputROMFile();
Expand Down
Loading
Loading