Virtual REU OS
Suche
Index
FAQ
Kontakt
Zurück
!to "reuvos.prg"
;--------------------------------------------------   
; Virtual REU OS V1
;
; Tiny Basic extender for the C64+REU.
; Overview : 
;    <-D : Detect REU (!!! REWRITES ALL BANKS !!!)
;    <-S : Stash Basic RAM ($0801-$A000)
;    <-F : Fetch Basic RAM ($0801-$A000)
;    <-B,{bank} : switch RAM banks
;    <-U,{C64-Adr.},{REU-Adr.},{bank},{bytes},{command} 
;      :User command  
; -------------------------------------------------   
;   Code : Michael Sachse (cbmhardware /PoL)
;   06.02.2005 : Init runs "Detect", counting banks fixed; 
; -------------------------------------------------   
; Licence : GPL
; This program is free software; you can redistribute it and/or modify it under the terms of the 
; GNU General Public License as published by the Free Software Foundation
; either version 2 of the ; License, or (at your option) any later version. 
;
;--------------------------------------------------   
* = $c000		; Start Address 49152
;--------------------------------------------------   
reubase= $df00   
CHRGET = $0073
TXTPTR = $7A
IERROR = $0300
IMAIN  = $0302
IGONE  = $0308
GONE   = $A7E4
CHKCOM = $AEFD
FRMNUM = $AD8A
GETADR = $B7F7
CHROUT = $FFD2
banks  = $90
usebank = $92
banktable = $c600
get = $ffe4             ; to get pressed keys
;--------------------------------------------------   
           lda #03
           sta 45               ; Basic low
           lda #08
           sta 46               ; Basic high 
           jsr $a68e            ; init          
freebanks  ldy #$00             ; delete banktable
f1         lda #70
           sta banktable,y
           iny
           cpy #32	  
           bne f1
           LDA #$93 
           JSR $FFD2  
           lda #1           
           sta $0286            ; textcolor white
           lda #0
           sta $d020
           sta $d021            ; black is beautiful  
           ldy #$00
title      lda TITLE,y          ; text
           JSR CHROUT
           iny
           cpy #40	  
           bne title
           jsr redet
INIT	   LDX #NEWBASIC
           STX IGONE
           STY IGONE+1
	   RTS
           LDX #$83
           LDY #$A4
           STX IMAIN            ; ($0302)
           STY IMAIN+1          ; ($0303)
NEWBASIC   JSR CHRGET           ; GET CHARACTER
           CMP #95              ; IS IT A "<-" ?
           BEQ CHK              ; YES, CONTINUE
           JMP GONE+3           ; NORMAL WORD
CHK        JSR CHRGET           ; GET NEXT CHARACTER
           CMP #$44             ; "D" Detect
           BEQ reumain
           CMP #$42             ; "B" Bank,?
           BEQ getBank
           CMP #$53             ; "S" Stash ($0800-$a000)
           BEQ stashreu
           CMP #$46             ; "F" Fetch ($0800-$a000)
           BEQ fetchreu1	
           CMP #$55             ; "U" User,c64,reu,bank,bytes,command (stash,fetch,swap)
           BEQ userreu
           JMP (IERROR)
;--------------------------------------------------
redet      jsr reudetect        ; detect REU (Banks)
           rts  

reumain    jsr reudetect        ; detect REU (Banks)
s          JMP GONE
;--------------------------------------------------
; Bank change <-B,{bank}
;--------------------------------------------------

getBank    JSR WORK1            
           sta bank+1
           sta usebank
s6         JMP STATUS


;--------------------------------------------------
; Stash  (Basic RAM $0801-$a000)
;
; Token : <-S
;
; Asks before rewriting if bank is in use. Smart eh ? ;)
;
;--------------------------------------------------

stashreu   ldx usebank
           lda banktable,x      ; check banktable
           cmp #85              ; "U" Bank in use
           bne doit             ; no, skip  
           ldy #00              ;   
t1         lda bankuse,y
           JSR CHROUT
           iny
           cpy #20
           bne t1
keyb       jsr get              ; get keyboard
           cmp #89              ; "Y"
           beq doit             ; 
           cmp #78              ; "N"
           beq exit
           bne keyb          
doit       lda #01
           sta c64lo+1
           lda #08
           sta c64hi+1
           lda #$00
           sta rbytes+1
           lda #$a0
           sta rbytesh+1
           lda #236
           sta config
           ldx usebank
           lda #85
           sta banktable,x 
           jsr main
exit       JMP GONE    
;--------------------------------------------------   
fetchreu1 jsr fetchreu
          rts
;--------------------------------------------------   
; User-Token: <-U,c64,reu,bank,bytes,command 
;
; Not rookies choice !
;            
;--------------------------------------------------   

userreu    jsr WORK1
           sta c64lo+1
           stx c64hi+1
           jsr WORK1 
           sta reulo+1
           stx reuhi+1
           jsr WORK1
           sta bank+1
           jsr WORK1
           sta rbytes+1
           stx rbytesh+1
           jsr WORK1
           sta config
           jsr main
ex1        JMP STATUS
;--------------------------------------------------
; Fetch (Basic RAM $0801-$a000)
;
; Token : <-F
;
; Asks before fetching if bank is empty. 
;
;--------------------------------------------------

fetchreu   ldx usebank
           lda banktable,x
           cmp #70             ;"F" bank free ? 
           bne doit1           ; no skip
           ldy #00 
t4         lda bankempty,y
           JSR CHROUT
           iny
           cpy #23
           bne t4
keyb1      jsr get             ; get keyboard
           cmp #89             ; "Y"
           beq doit1           
           cmp #78             ; "N"
           beq ex2
           bne keyb1         
doit1      lda #01
           sta c64lo+1
           lda #08
           sta c64hi+1
           lda #$00
           sta rbytes+1
           lda #$a0
           sta rbytesh+1
           lda #237
           sta config
           jsr main
ex2        JMP GONE
;--------------------------------------------------   
; Basic ROM patch 
;--------------------------------------------------   
WORK1      JSR CHRGET           ; 
           LDA #$2C             ; Comma patch 
           ldy #$00             ; Pointer 
           CMP($7a),y           ; compare 
           BEQ WORK1            ; Comma, loop       
           JSR $AD8A            ; FRMNUM        
           JSR $B1BF            ; GET C64 Adr. 
           LDA $65              ; low byte
           LDX $64              ; high byte 
           RTS
;--------------------------------------------------
; Detect REU 1700,1764/50 or 1/2MB
;--------------------------------------------------
reudetect    lda #00
             sta c64lo+1
             lda #$C3
             sta c64hi+1
             lda #16
             sta rbytes+1
             lda #00
             sta rbytesh+1
             sta banks
             sta reubase
             cmp reubase
             beq noreu       
             bne unsafe
unsafe       lda reubase
             and #16            ; check bit 4 for REU mem
             cmp #16            ; 16 = 256Kbx1 
             beq regcheck       ; yes, touch registers
             bne l1             ; no, 1700 ?
l1           lda reubase
             and #16            ; check bit 4 for REU mem
             cmp #0
             beq r1700          ; reu 1700 found
             bne noreu          ; no ram-type, no reu, no fun ...
regcheck     lda reubase
             ldx #2
loop1        txa
             sta $df00,x        ; write to registers 2-5                                         
             inx
             cpx #5
             bne loop1
             ldx #02 
loop2        txa 
             cmp $df00,x             
             bne noreu 
             inx
             cpx #5
             bne loop2
             jmp rinit
r1700        lda #1
             sta banks
             lda #reutext              
             jmp $ab1e
;-------------------------------------------------
rinit        ldx #00          ; 1764 wake up
rinit2       lda #128         ; stash 
             sta config
             lda #$12         ; write some crap in ... 
             sta c64hi+1
             stx bank+1
             jsr main         
             inx
             cpx #33          ;  ... 33 banks into somewhere
             bne rinit2
             jmp action
noreu        lda #notext              
             jmp $ab1e
;--------------------------------------------------
; Count banks 
;--------------------------------------------------
action       lda reubase
             ldx #$00
             stx bank+1       ; reset bank counter
check        lda #129         ; fetch : transfer to C64 :  
             sta config        
             lda #$C7         ; C64 : $C700 
             sta c64hi+1 
             jsr main 
             lda #128         ; stash 
             sta config
             lda #$C3         ; write dummy bytes  
             sta c64hi+1
             jsr main         
             jsr bankcheck    ; check for existing ram banks
             inx 
             cpx #33          ; try 33 
             stx bank+1
             bne check
;--------------------------------------------------
             lda #0           ; restore bordercolor 
             sta $d020 
             lda banks        ; banks found ? 
             cmp #4
             beq r1764        
             bne j1
r1764        lda #4
             sta banks 
             dec banks
             lda #text1764              
             jmp $ab1e
j1           cmp #8
             beq r512
             bne j2 
r512         dec banks
             lda #reut512              
             jmp $ab1e
j2           cmp #16
             beq r1024
             bne j3     
r1024        dec banks
             lda #reut1024              
             jmp $ab1e
j3           cmp #20
             beq r1764
             bne j4
j4           cmp #32
             beq r2048
             bne j6 
r2048        dec banks
             lda #reut2048              
             jmp $ab1e
j6           lda #reuunk              
             jmp $ab1e
;--------------------------------------------------
; Bank Check
;--------------------------------------------------
bankcheck    ldy #$00       
l2           lda $C300,y
l6           cmp $C700,y             
             bne l4            ; bank found ? 
             beq l3            ; no, check 16 Bytes 
l3           iny            
             cpy #16 
             bne l2            ; loop  
end          ldy #00
             lda #00
delete       sta $C700,y       ; delete buffer
             iny
             cpy #16
             bne delete        
             rts
l4           jmp l5 
l5           inc banks         ; bank found (inc), border color change and exit
             inc $d020 
             rts
config !byte 252
;--------------------------------------------------
; Bytes and text
;--------------------------------------------------
*=$C300 

!scr "---C64-RULEZ!---"         ;  ;-)
                     
reutext:  !text "REU 1700 : 128KB DETECTED",0
text1764: !text "REU 1764 : 256KB DETECTED",0
reut512:  !text "REU 1750 : 512KB DETECTED",0
reut1024: !text "REU 1024KB DETECTED",0
reut2048: !text "REU 2048KB DETECTED",0
reuunk:   !text "REU PORT DETECTED - BANK ERROR",0
bankerr:  !SCR "BANK ERROR"
notext:   !text "NO REU",0
bankuse : !SCR "REWRITE BANK [Y/N] ?"
bankempty : !SCR "READ EMPTY BANK [Y/N] ?"
;--------------------------------------------------
; REU TRANSFER ROUTINE
;--------------------------------------------------
main       lda config
           sta reubase+1 
c64lo      lda #$00
           sta reubase+2
c64hi      lda #$C2             
           sta reubase+3
reulo      lda #$00
           sta reubase+4
reuhi      lda #$00
           sta reubase+5
bank       lda #00
           sta reubase+6        ; Bank
rbytes     lda #16  
           sta reubase+7        ; 16 Bytes
rbytesh    lda #$00
           sta reubase+8
irq        lda #$00
           sta reubase+9
           lda #$00
           sta reubase+10 
           lda $1
           pha
           lda #$30             ; RAM
           sei
           sta $1
           sta $ff00                   
           pla
           sta $1
           cli
           rts
;--------------------------------------------------
; Restore TXTPTR and back to command line
;--------------------------------------------------

STATUS	
END2       SEC
           LDA TXTPTR
           SBC #$01
           STA TXTPTR
           LDA TXTPTR+1
           SBC #$00
           STA TXTPTR+1
           JMP GONE
;--------------------------------------------------
TITLE	 !SCR " **** VIRTUAL REU OS V1 INSTALLED  **** "
flinit !BYTE 73

 

Letzte Änderung: 2019-01-03 18:14:50
  Rubrik:  C64
Rubriken-Übersicht
 3 Besucher online 

Valid XHTML 1.0 Transitional Valid CSS!