Skip to content

Commit

Permalink
Merge pull request #45 from Pinacolada64/scripts
Browse files Browse the repository at this point in the history
Fix-ups for asm, readability, +.IM
  • Loading branch information
Pinacolada64 committed Feb 20, 2019
2 parents 14e5f03 + 7f7cef1 commit 8a7e2d0
Show file tree
Hide file tree
Showing 19 changed files with 461 additions and 153 deletions.
74 changes: 74 additions & 0 deletions scripts/github-rename.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
#!/bin/bash

# Loop through a directory of *.lbl filenames, fixing an issue where
# DirMaster for Windows exports Commodore filenames with "/" in them
# "i/lo.blah" -> "i- lo.blah"

# http://tldp.org/LDP/abs/html/string-manipulation.html
# (Substring Replacement)
use_slashes=1

function translate_filename()
# this translates the filename given and returns in $test
{
stringZ=(basename "$1")
# compare=(basename "$1")
# // delimiter replaces globally; / replaces first occurrence
echo "Input : $stringZ"
test=${stringZ//plus/+} # plus to +
echo "Step 1: $test"
if [ "$use_slashes" == "1" ]; then
test=${test//\ -\ /\/} # " - " to / -- escape " " and /!
else
test=${test//slash/-} # slash to -
fi;
echo "Step 2: $test"
test=${test//./_} # . to _
echo "Step 3: $test $stringZ"
[ "$stringZ" != "$test" ] && echo "Unequal."; exit 0 # success, git mv them
echo "Strings equal." && exit 1
}

CURRENT_DIR=$PWD
cd ../v2/core/jack
# can't use "find ../v2/core/jack/foo_bar.lbl" because ".." will be translated to "__"

translate_filename "i - bla.bla"; echo $test

find . -name '*.lbl' | \
while read fname ;
fname=${fname//.lbl/} # strip .lbl extension to not transform to "_lbl"
do translate_filename "$fname";
echo "Status: $?"
if [ "$?" == "1" ]; then
echo "$fname.lbl: No transformation required"
else
echo "git mv $fname.lbl $test.lbl"
fi;
done

echo ${file##*/}

# old_filename="$1" # "plusslashMM_load.lbl"

translate_filename "$old_filename" # "+/MM.load.lbl"
C64_FILE=${test//.lbl/} # remove .lbl extension

# translate_filename "plusplus 2" # "++ 2.prg"
echo "input_lbl=$input_lbl"
echo "C64_FILE=$C64_FILE"

# quote filenames since some have spaces in them
echo "wine c64list3_05.exe \"$input_lbl\" -prg -ovr"

# fluffy's sed script
# find . -name '*.lua' | while read fname ; do sed s/cat/dog/g "$fname" > "$fname.new" ; mv "$fname.new" "$fname" ; done

# find ../v2/core/jack -name '*.lbl' | while read fname ;
# do translate_filename $fname ;
# if [ "$?" = "1" ]; then
# echo "git mv $fname $test";
# fi;
# done

cd $CURRENT_DIR # return to where we were
60 changes: 60 additions & 0 deletions v1.2/core/edata-edit.lbl
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
{number:0}
{step:1}
n$=chr$(0):r$=chr$(13):goto {:100}
{number:1}
{:1}
gosub {:2}:for s=1 to 50:next
{number:2}
{:2}
print# 15,"p{$02}"chr$(x and 255)chr$(x/256)"{$01}":return
{number:5}
{:5}
x=rn:gosub {:1}:ed$=""
{number:6}
{:6}
get#2,b$:b$=chr$(asc(b$+n$)):if b$<>chr$(13) then ed$=ed$+b$:goto {:6}
return
{number:10}
{:10}
for i=1 to len(ed$):z$=mid$(ed$,i,1):a=asc(z$+n$)
if (a>32 and a<128) or a>159 then print z$;:goto {:15}
if a<>34 then print"{rvrs on}"chr$(a+64)"{rvrs off}";:goto {:15}
print z$ chr$(20)z$;:goto {:15}
{number:15}
{:15}
next:print:return
{number:100}
{:100}
rn=.:print"{clear}{lower}Insert Your Etcetera Disk In Any{$a0}Drive."
input"Device 8{left:3}";dv%:input" Drive 0{left:3}";dr$
open 15,dv%,15:open 2,dv%,2,dr$+":e.data":input# 15,a,a$:if a then {:900}
{:103}
rn=rn+1:if rn>32 then rn=32
{:104}
print"{down:2}Record # To Edit, {rvrs on}L{rvrs off} To List All,":print"Or {rvrs on}Q{rvrs off}{$a0}to Quit ";
print mid$(str$(rn),2)"{left:4}";:if rn<10 then print"{right}";
input a$:if a$="q" OR a$="Q" then close 2:close 15:end
if a$="l" or a$="L" then {:350}
rn=abs(int(val(left$(a$,2)))):if rn<1 or rn>32 then rn=1:goto {:104}
gosub {:5}:gosub {:10}:b$="":print"{down}Type Changes. Return When Finished."
{number:112}
{step:2}
{:112}
if len(b$)=32 then {:126}
{:114}
print"{rvrs on} {rvrs off}{left}";:wait 198,1:get a$:a=asc(a$+n$):on -(a=34) goto {:122}:if a=13 then {:124}
if (a>32 and a<128) or a>159 then b$=b$+a$:print a$;:goto {:112}
if (a<>20 and a<>148) or peek(653)=4 then b$=b$+chr$(a):print"{rvrs on}"chr$(a+64)"{rvrs off}";:goto {:112}
on len(b$)+1 goto {:114}:b$=left$(b$,len(b$)-1):print a$;:goto {:112}
{:122}
print a$ chr$(20)a$;:b$=b$+a$:goto {:112}
{:124}
IF LEN(b$)=. then b$=ed$:print"(Unchanged.)":goto {:103}
{:126}
print:print "Writing...":x=rn:gosub {:1}:print# 2,b$:goto {:103}
{number:350}
{:350}
for rn=1 to 32:print rn":";:gosub {:5}:gosub {:10}:rn=rn+peek(198)*32:next:rn=1:goto {:104}
{number:900}
{:900}
print"Disk Error: "a","a$:close 2:close 15:end
7 changes: 2 additions & 5 deletions v2/asm/equates-2_0.lbl
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
{asm}
; to include:
; {uses:..\asm\equates-2_0.lbl}
;
; image 2.0 equates
;
Expand All @@ -16,7 +13,8 @@
scs = $dc09 ; seconds
min = $dc0a ; minutes
hrs = $dc0b ; hours
carrier = $dd01 ; needed by irqhn.s
; carrier = $dd01 ; This definition conflicts with $d009;
; "carrier" is referenced by irqhn.s
; 56577: CIA #2 Data Port B
; Bit 4: RS-232 carrier detect (DCD)/ Pin H of User Port
colors = $e8da ; flashing chat page color table
Expand Down Expand Up @@ -337,4 +335,3 @@
arraysav= wedgemem+9
arrayres= wedgemem+12
forcegc = wedgemem+15
{endasm}
75 changes: 56 additions & 19 deletions v2/asm/rs232-swift.lbl
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
; for pass=1 to 3:org $0800,-(pass=3),8,"@:ml.rs232/swift"

{include:equates-2_0.lbl}
orig $c000
{asm}
orig $0800
baudof = $299
rodbe = $29e
rodbs = $29d
Expand All @@ -22,21 +21,24 @@ orig $c000
io1 = $de00
io2 = $df00
port = io1
rs_stat = port+1
sl_stat = port+1
command = port+2
control = port+3

; SwiftLink commands:
comint0 = {%:00001010} ; nmi off
comint1 = {%:00001001} ; rxd on
comint2 = {%:00000101} ; txd/rxd
comdtr0 = {%:00001000} ; dtr off
comrts0 = {%:00000001} ; rts off

; SwiftLink statuses:
statdcd = {%:01000000} ; carrier
statrxd = {%:00001000} ; receive
stattxd = {%:00010000} ; transmit
statint = {%:10000000} ; nmi

; Carrier Detect:
imagecd0= {%:00000000} ; none
imagecd1= {%:00010000} ; carrier

Expand Down Expand Up @@ -92,7 +94,7 @@ oldget:
byte 0

setup:
lda #comint0
lda #comint0 ; interrupts off?
sta command
ldx #0
lda #3
Expand All @@ -119,17 +121,56 @@ setup2:
jmp setup1
setup3:
lda #0
sta rs_stat
lda #comint1
sta sl_stat ; reset 6551
lda #comint1 ; rxd on
sta shcomm
jsr inable
jsr setcarr
lda #2

; .------------------------- 0 = one stop bit
; :
; :.-------------------- word length, bits 6-7
; ::.------------------- 0 = eight bit word
; :::
; :::.-------------- clock source, 1 = internal generator
; ::::
; ::::.----- baud
; :::::.---- rate
; ::::::.--- bits
; :::::::.-- 0-3
; bit 76543210
lda #{%:00011010}
sta control

; The ACIA "command" register controls the parity, echo mode, transmit and
; receive interrupt enabling, hardware "BRK", and (indirectly) the "RTS"
; and "DTR" lines. The value below sets the ACIA for no parity check,
; no echo, disables transmit interrupts, and enables receive interrupts
; (RTS and DTR low).

; .------------------------- parity control,
; :.------------------------ bits 5-7
; ::.----------------------- 000 = no parity
; :::
; :::.----------------- echo mode, 0 = normal (no echo)
; ::::
; ::::.------------ transmit interrupt control, bits 2-3
; :::::.----------- 10 = xmit interrupt off, RTS low
; ::::::
; ::::::.------- receive interrupt control, 0 = enabled
; :::::::
; :::::::.--- DTR control, 1 = DTR low
; bit 76543210
; lda #{%:00001001} ; no parity
lda #{%:11101001} ; space parity
sta command

lda #2 ; 1200 baud
jmp setbaud

setcarr:
ldy #imagecd1
lda rs_stat
lda sl_stat
and #statdcd
beq setcarr1
ldy #imagecd0
Expand All @@ -146,7 +187,7 @@ nmi64:
tya
pha
cld
lda rs_stat
lda sl_stat
and #statint
beq notacia
lda #comint0
Expand All @@ -169,7 +210,7 @@ notacia:
;
rsint:
jsr setcarr
lda rs_stat
lda sl_stat
and #statrxd
beq rsint2
lda port
Expand All @@ -192,7 +233,7 @@ rsint1:
; ** check transmit
;
rsint2:
lda rs_stat
lda sl_stat
and #stattxd
beq rsint4
lda shcomm
Expand Down Expand Up @@ -366,10 +407,10 @@ setbaud3:
sta control
rts

;nchrout:
; jsr disabl
; jsr oldout
; jmp inable
nchrout:
jsr disabl
jsr oldout
jmp inable

nopen:
jsr disabl
Expand All @@ -390,7 +431,3 @@ nchrin:
jsr disabl
jsr oldchr
jmp inable

; last:
; next pass:close 8:print last-first "bytes."
{endasm}
Loading

0 comments on commit 8a7e2d0

Please sign in to comment.