Files
Shawn Quick dfcaae62dd Add qlink, the disk tools, and a bootable ProDOS 8 image.
Move the assembler to src/qasm. qlink links OMF 1.0 and 2.0 from a script. makeBin flattens a load file, qomf dumps OMF, and qpro builds ProDOS volumes. APW and MPW assemble through the ORCA front end. Relocatable modules emit OMF objects. Listings stay off unless -l is set.

make boot assembles the GS/OS 6.0.1 ProDOS 8 kernel and BASIC.SYSTEM into an 800K volume. BASIC.SYSTEM accepts ls and pfx, and its splash reports PRODOS BASIC 2.0, copyright 1983-2026. IIGS.601.SRC is the source and the BASIC.SYSTEM oracle that image is built from.
2026-10-16 14:41:55 -07:00

1 line
8.1 KiB
Plaintext

Print off
;-----------------------------------------------
;
; Imported addresses
;
;-----------------------------------------------
IMPORT GAdrL
IMPORT GDataReg
IMPORT GPtrInc
IMPORT GStatReg
IMPORT SysVol
IMPORT doc_ctrl
IMPORT doc_halt_reset
IMPORT errBadGenNum
IMPORT errNoneAvail
IMPORT gcb_ID
IMPORT long
IMPORT osc_table
IMPORT short
Print on
****************************************************************
*
* AllocGen
*
* Inputs: Priority Requested
*
* Outputs: Generator Number
*
*
****************************************************************
*
EXPORT AllocGen
AllocGen PROC
Print off
INCLUDE 'gcb.aii'
INCLUDE 'ns.equ'
INCLUDE 'Note.Macros'
INCLUDE 'E16.NoteSyn'
INCLUDE 'E16.MIDI'
print on, noGen, NoHdr, NoMdir
longi on
longa on
GenNum equ 13+6 ; output word
Priority equ 11+6 ; input: priority of request
RTL1 equ 8+6
RTL2 equ 5+6
OldDP equ 3+6 ; caller's Direct Page
OldPS equ 2+6 ; caller's status reg
OldB equ 1+6
phd ;save old DP
tcd ;use WAP as DP
bne @1
ldy #errNotStarted ; report error.
php ; push this so we can call byebye ...
phb ; ...without trashing the stack.
jmp byebye
@1 php ;save callers IRQ status
sei ; NOT REENTRANT!
phb ; save the callers bank.
pei min ; Save DP values incase some one else
pei Priority_Table ; is using them
pei Priority_Table+2 ;
* Now make a DP pointer to the priority table
lda >myram_ptr
sta Priority_Table
lda >myram_ptr+2
sta Priority_Table+2
* Now here's the main loop. We are looking for a free generator, which
* will be flagged by a 0 priority. If there are none of those, then we
* want the lowest priority generator. We'll keep a variable, called
* min, and keep the min's generator number in x.
mem_short
lda #255 ; initialize min to max
sta min
ldy #0
* FOR Y = 0 TO num_of_gen-1
look lda [priority_table],y ; Get the Priority of osc y.
beq found_zero
bmi sacred ; Can't steal a priority of 128 or more.
dec a ; make old notes more desirable
bne over1 ; by decrementing their priority
inc a ; down to, but not past 1.
over1 cmp min
bge too_high ; If >= min then continue(save new priority).
sta min ; Else save priority as new min, and
tyx ; hold min's gen num in x
too_high sta [priority_table],y ; save priority of osc y.
sacred iny ; NEXT Y
cpy #4 ; Time for first MIDI poll?
beq @1 ; Should we poll MIDI?
cpy #9 ; Time for second MIDI poll?
bne @2 ; if time, poll, else check if done.
@1 jsr PollMIDI ; Time to poll MIDI.
@2 cpy #num_of_gen ; See If done.
bne look ; If not look again.
jsr PollMIDI ; else Poll MIDI.
* if we get here, then there were no free generators. See if there were any
* that had a priority low enough to steal.
lda min
bmi none_avail
cmp Priority,s ; here's the lowest one. is it lower
bge none_avail ; that the request priority?
txy ; YES? then use it!
* When we get here, then y has the gen num of the one we'll give away.
found_zero tya
mem_long ; store the whole thing
and #$000F ; legal values in $00..$0D 8/19/87 md
sta GenNum,s ; pass the output back
tay ; Make sure y isn't trashed.
mem_short ; store only one byte
lda Priority,s ; and assign the new priority
sta [priority_table],y ; Save priority of osc Y.
mem_long
* Clean up the stack and leave happy.
ldy #0
exit pla ; Restore DP values.
sta Priority_Table+2
pla
sta Priority_Table
pla
sta min
byebye plb ; restore status, bank, and DP of caller.
plp
pld
lda 5,s ; Move RTL's up two bytes.
sta 7,s
lda 3,s
sta 5,s
lda 1,s
sta 3,s
pla ; throw away these two bytes
tya ; restore error status
cmp #1 ; set carry if an error
rtl ; >>>-------- EXIT --------->>>
none_avail mem_long
ldy #errNoneAvail ; error condition: no gens available
bra exit
eject
********************************************************************************
*
* PollMidi
*
* preserve P, A, X, Y. and call MIDIInputPoll.
*
********************************************************************************
Export PollMidi
PollMidi
php
both long
pha
phx
phy
JSL MIDIInputPoll
ply
plx
pla
plp
rts
eject
****************************************************************
*
* DeAllocGen
*
* Inputs: Generator Number
*
* Outputs: This routine zeros the priority and gcb_ID byte of
* the generator, and halts both of the oscillators.
*
****************************************************************
*
EXPORT DeAllocGen
DeAllocGen ;
longi on
longa on
oldgen equ 11 ; input
* Note that this is the same segment as AllocGen.
phd ;save old DP
tcd ;use WAP as DP
php ;save callers IRQ status
sei ; NOT REENTRANT!
phb ; save the callers bank.
tdc ; See if started up.
bne @1 ; if not equal we were started.
ldy #nsNotInit ; otherwize we weren't startedd,
jmp byebye ; return error and exit.
@1 lda myram_ptr+1 ; get my bank
pha ; and put on stack.
plb ; pull byte 2
plb ; pull byte 3 or bank.
* The stack frame, from now on, looks like this:
* oldgen equ 11 ; input
* rtl equ 8
* rtl equ 5
* olddp equ 3 ; caller's Direct Page
* oldp equ 2 ; caller's status reg
* oldb equ 1
* The first order of business is to make sure we're alive
both short ; do this like a 6502
lda oldgen,s
tay ; gennum temp in y
cmp #num_of_gen
bge bad_arg
asl a ; create the GCB address
asl a
asl a
asl a
tax
stz <gcb_ID,x ; clear the ID byte
tyx
lda #0 ; and the priority byte
phd ; save, new dp will be on stack.
tay ; save the acc.
; for rom sta priority_table,x must be rewritten.
lda myram_ptr+3 ; pushlong myram_ptr
pha
lda myram_ptr+2
pha
lda myram_ptr+1
pha
lda myram_ptr+0
pha
tsc ; get stack.
tcd ; and make it dp.
tya ; get the acc back.
txy ; get the y value.
sta [1],y ; get the value.
pla ; and restore stack.
pla
pla
pla
pld ; restore dp.
lda >osc_table,x ; get doc address
clc
adc #doc_ctrl
sta >GAdrL
lda >SysVol
ora #GPtrInc
sta >GStatReg
lda #doc_halt_reset
sta >GDataReg
sta >GDataReg ; halt both oscillators
* Clean up the stack and leave happy.
both long
ldy #0
jmp byebye
bad_arg both long
ldy #errBadGenNum
jmp byebye
ENDP
eject
end