├── source
├── version.txt
├── version-msx.asm
├── version.asm
├── chrset.bin
├── retrologo.mseq
├── intro_sc.asm
├── intro_sc.petmate
└── retrotermp4.asm
├── .gitignore
├── docs
├── turbo56k.png
└── turbo56k.md
├── LICENSE
├── Makefile
└── README.md
/source/version.txt:
--------------------------------------------------------------------------------
1 | 0.30b
--------------------------------------------------------------------------------
/source/version-msx.asm:
--------------------------------------------------------------------------------
1 | DB "0.30b"
2 |
--------------------------------------------------------------------------------
/source/version.asm:
--------------------------------------------------------------------------------
1 | !text "0.30b"
2 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | build/*.lst
2 | build/*.symbol
3 |
--------------------------------------------------------------------------------
/docs/turbo56k.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/retrocomputacion/retroterm/HEAD/docs/turbo56k.png
--------------------------------------------------------------------------------
/source/chrset.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/retrocomputacion/retroterm/HEAD/source/chrset.bin
--------------------------------------------------------------------------------
/source/retrologo.mseq:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/retrocomputacion/retroterm/HEAD/source/retrologo.mseq
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright 2022 Jorge Castillo & Pablo Roldán
2 |
3 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4 |
5 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
--------------------------------------------------------------------------------
/Makefile:
--------------------------------------------------------------------------------
1 | default: all
2 |
3 | BUILDFOLDER:=build
4 | SRCFOLDER:=source
5 |
6 | CBMVARIANTS=cbm-u cbm-sl cbm-ulti cbm-232
7 | MSXVARIANTS=msx-232 msx-56k msx-38k msx-badcat
8 |
9 | DEFINES_FOR_cbm-u=-D_HARDTYPE_=56
10 | DEFINES_FOR_cbm-sl=-D_HARDTYPE_=38
11 | DEFINES_FOR_cbm-ulti=-D_HARDTYPE_=1541
12 | DEFINES_FOR_cbm-232=-D_HARDTYPE_=232
13 | DEFINES_FOR_msx-232=-E IFACE=0
14 | DEFINES_FOR_msx-badcat=-E IFACE=1
15 | DEFINES_FOR_msx-56k=-E IFACE=56
16 | DEFINES_FOR_msx-38k=-E IFACE=38
17 |
18 |
19 |
20 | # Create build directories
21 | $(BUILDFOLDER) $(BUILDFOLDER)/packed:
22 | mkdir -p $@
23 |
24 | # Read build version from source/version.txt
25 | VERSION := $(shell cat $(SRCFOLDER)/version.txt)
26 |
27 | define make_target_acme
28 | $(BUILDFOLDER)/rt-$(1).prg: $(SRCFOLDER)/retroterm_univ.asm $(SRCFOLDER)/version.asm | $(BUILDFOLDER) $(BUILDFOLDER)/packed
29 | acme $$(DEFINES_FOR_$(1)) -D_MAKE_=1 -I $(SRCFOLDER) -f cbm -l $(BUILDFOLDER)/rt-$(1).lst -o $$@ $$<
30 | exomizer sfx basic -o $(BUILDFOLDER)/packed/$$(@F) $$@
31 |
32 | endef
33 |
34 | define make_target_pasmo
35 | $(BUILDFOLDER)/rt-$(1).com: $(SRCFOLDER)/retrotermm1.asm $(SRCFOLDER)/retrologo.mseq $(SRCFOLDER)/version-msx.asm
36 | pasmo $$(DEFINES_FOR_$(1)) -I $(SRCFOLDER) $(SRCFOLDER)/retrotermm1.asm $(BUILDFOLDER)/rt-$(1).com $(BUILDFOLDER)/rtm-$(1).symbol
37 |
38 | endef
39 |
40 | # Main targets
41 | # all: $(SRCFOLDER)/version.asm $(foreach variant,$(CBMVARIANTS),$(BUILDFOLDER)/rt-$(variant).prg) plus4 \
42 | # $(foreach variant,$(MSXVARIANTS),$(BUILDFOLDER)/rt-$(variant).com)
43 | all: version cbm msx
44 |
45 | cbm: $(SRCFOLDER)/version.asm $(foreach variant,$(CBMVARIANTS),$(BUILDFOLDER)/rt-$(variant).prg) plus4
46 |
47 | msx: $(SRCFOLDER)/version-msx.asm $(foreach variant,$(MSXVARIANTS),$(BUILDFOLDER)/rt-$(variant).com)
48 |
49 | swiftlink: $(BUILDFOLDER)/rt-cbm-sl.prg
50 |
51 | ultimate: $(BUILDFOLDER)/rt-cbm-ulti.prg
52 |
53 | turbo232: $(BUILDFOLDER)/rt-cbm-232.prg
54 |
55 | userport: $(BUILDFOLDER)/rt-cbm-u.prg
56 |
57 | plus4: $(BUILDFOLDER)/rt-cbm-p4.prg
58 |
59 | msx232: $(BUILDFOLDER)/rt-msx-232.com
60 |
61 | msxbadcat: $(BUILDFOLDER)/rt-msx-badcat.com
62 |
63 | msx56k: $(BUILDFOLDER)/rt-msx-56k.com
64 |
65 | msx38k: $(BUILDFOLDER)/rt-msx-38k.com
66 |
67 | version: $(SRCFOLDER)/version.asm $(SRCFOLDER)/version-msx.asm
68 |
69 | # Special case for p4 (uses different source file)
70 | $(BUILDFOLDER)/rt-cbm-p4.prg: $(SRCFOLDER)/retrotermp4.asm | $(BUILDFOLDER) $(BUILDFOLDER)/packed
71 | acme -f cbm -D_MAKE_=1 -I $(SRCFOLDER) -l $(BUILDFOLDER)/rt-cbm-p4.lst -o $(BUILDFOLDER)/rt-cbm-p4.prg $(SRCFOLDER)/retrotermp4.asm
72 | exomizer sfx basic -t4 -o $(BUILDFOLDER)/packed/rt-cbm-p4.prg $(BUILDFOLDER)/rt-cbm-p4.prg
73 |
74 | # Generate version includes
75 | $(SRCFOLDER)/version.asm: $(SRCFOLDER)/version.txt | $(SRCFOLDER)
76 | echo !text '"'$(VERSION)'"' > $(SRCFOLDER)/version.asm
77 | $(SRCFOLDER)/version-msx.asm: $(SRCFOLDER)/version.txt | $(SRCFOLDER)
78 | echo DB '"'$(VERSION)'"' > $(SRCFOLDER)/version-msx.asm
79 |
80 | # Generate rules dynamically
81 | $(eval $(foreach variant,$(CBMVARIANTS),$(call make_target_acme,$(variant))))
82 | $(eval $(foreach variant,$(MSXVARIANTS),$(call make_target_pasmo,$(variant))))
83 |
84 | # Clean target
85 | clean:
86 | rm -rf $(BUILDFOLDER)
--------------------------------------------------------------------------------
/source/intro_sc.asm:
--------------------------------------------------------------------------------
1 |
2 |
3 | ; PETSCII memory layout (example for a 40x25 screen)'
4 | ; byte 0 = border color'
5 | ; byte 1 = background color'
6 | ; bytes 2-1001 = screencodes'
7 | ; bytes 1002-2001 = color
8 |
9 | screen_001:
10 | !byte 1,1
11 | !byte $20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20
12 | !byte $20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20
13 | !byte $20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20
14 | !byte $20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20
15 | !byte $20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20
16 | !byte $20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20
17 | !byte $20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20
18 | !byte $20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$E1,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20
19 | !byte $20,$7C,$E2,$E2,$E2,$E2,$E2,$E2,$E2,$E2,$7E,$FF,$E2,$E2,$6C,$E2,$E2,$7F,$7C,$FB,$E2,$6C,$E2,$E2,$7E,$FF,$E2,$E2,$7B,$E2,$E2,$E2,$E2,$E2,$E2,$E2,$E2,$E2,$7E,$20
20 | !byte $7C,$E2,$E2,$E2,$E2,$E2,$E2,$E2,$E2,$E2,$7E,$61,$20,$20,$E1,$E2,$E2,$E2,$20,$E1,$20,$E1,$20,$20,$20,$61,$20,$20,$61,$E2,$E2,$E2,$E2,$E2,$E2,$E2,$E2,$E2,$E2,$7E
21 | !byte $7C,$E2,$E2,$E2,$E2,$E2,$E2,$E2,$E2,$E2,$7E,$7E,$20,$20,$20,$E2,$E2,$E2,$20,$20,$E2,$7C,$20,$20,$20,$7C,$E2,$E2,$20,$E2,$E2,$E2,$E2,$E2,$E2,$E2,$E2,$E2,$E2,$7E
22 | !byte $20,$7C,$E2,$E2,$E2,$E2,$E2,$E2,$E2,$E2,$7E,$E2,$E2,$E2,$7C,$E2,$E2,$E2,$7C,$E2,$E2,$7C,$E2,$E2,$7E,$E2,$E2,$E2,$7E,$E2,$E2,$E2,$E2,$E2,$E2,$E2,$E2,$E2,$7E,$20
23 | !byte $20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$E1,$20,$20,$20,$20,$20,$20,$20,$20,$20,$7C,$20,$20,$20,$20,$20,$20,$20,$20
24 | !byte $6C,$E2,$E2,$E2,$6C,$E2,$E2,$7F,$E1,$E2,$EC,$7F,$E1,$E2,$E2,$7F,$E1,$20,$20,$E1,$7C,$FB,$E2,$20,$E2,$E2,$7F,$6C,$E2,$E2,$E2,$E1,$6C,$E2,$E2,$7F,$E1,$E2,$E2,$7B
25 | !byte $E1,$20,$20,$20,$E1,$20,$20,$E1,$E1,$20,$61,$E1,$E1,$20,$20,$E1,$E1,$20,$20,$E1,$20,$E1,$20,$6C,$E2,$E2,$FB,$E1,$20,$20,$20,$E1,$E1,$20,$20,$E1,$E1,$20,$20,$61
26 | !byte $20,$E2,$E2,$E2,$20,$E2,$E2,$7E,$7C,$20,$7E,$7C,$E1,$E2,$E2,$7E,$20,$E2,$E2,$7E,$20,$20,$E2,$20,$E2,$E2,$E2,$20,$E2,$E2,$E2,$7C,$20,$E2,$E2,$7E,$7C,$20,$20,$7E
27 | !byte $7C,$E2,$E2,$E2,$7C,$E2,$E2,$E2,$7C,$E2,$E2,$E2,$7C,$7C,$E2,$E2,$7C,$E2,$E2,$E2,$7C,$E2,$E2,$7C,$E2,$E2,$E2,$7C,$E2,$E2,$E2,$7C,$7C,$E2,$E2,$E2,$7C,$E2,$E2,$7E
28 | !byte $20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20
29 | !byte $20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20
30 | !byte $20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$52,$45,$54,$52,$4F,$43,$4F,$4D,$50,$55,$54,$41,$43,$49,$4F,$4E,$2E,$43,$4F,$4D,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20
31 | !byte $20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$10,$12,$05,$13,$05,$0E,$14,$01,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20
32 | !byte $20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20
33 | !byte $20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$52,$05,$14,$12,$0F,$14,$05,$12,$0D,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20
34 | !byte $20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20
35 | !byte $20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20
36 | !byte $0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E
37 | !byte $0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E
38 | !byte $0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E
39 | !byte $0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E
40 | !byte $0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E
41 | !byte $0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E
42 | !byte $0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E
43 | !byte $0E,$0E,$0E,$0E,$0E,$0E,$0E,$00,$00,$00,$00,$00,$00,$00,$00,$0E,$0E,$0E,$0E,$00,$00,$0E,$0E,$0E,$0E,$0E,$0E,$00,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E
44 | !byte $0E,$02,$02,$02,$02,$02,$02,$02,$02,$02,$02,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$02,$02,$02,$02,$02,$02,$02,$02,$02,$02,$0E
45 | !byte $07,$07,$07,$07,$07,$07,$07,$07,$07,$07,$07,$00,$0E,$0E,$00,$00,$00,$00,$02,$00,$00,$00,$00,$0E,$0E,$00,$0E,$00,$00,$07,$07,$07,$07,$07,$07,$07,$07,$07,$07,$07
46 | !byte $0D,$0D,$0D,$0D,$0D,$0D,$0D,$0D,$0D,$0D,$0D,$00,$0E,$0E,$0E,$00,$00,$00,$02,$0E,$00,$00,$00,$0E,$0E,$00,$00,$00,$02,$0D,$0D,$0D,$0D,$0D,$0D,$0D,$0D,$0D,$0D,$0D
47 | !byte $0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E
48 | !byte $0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$00,$00,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$00,$00,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E
49 | !byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$0E,$0E,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
50 | !byte $00,$00,$0E,$00,$00,$0E,$0E,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$0E,$0E,$00,$02,$00,$00,$00,$00,$00,$00,$00,$00,$0E,$00,$00,$00,$0E,$0E,$00,$00,$00,$0E,$00
51 | !byte $0E,$00,$00,$00,$0E,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$0E,$00,$00,$00,$02,$0E,$00,$00,$00,$00,$00,$0E,$00,$00,$00,$00,$0E,$00,$00,$00,$00,$00,$0E,$00
52 | !byte $0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$00,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E
53 | !byte $0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E
54 | !byte $0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E
55 | !byte $0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$06,$06,$06,$06,$06,$06,$06,$06,$06,$06,$06,$06,$06,$06,$06,$06,$06,$06,$06,$06,$06,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E
56 | !byte $0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$06,$06,$06,$06,$06,$06,$06,$06,$06,$06,$06,$06,$06,$06,$06,$06,$06,$06,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E
57 | !byte $0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$06,$0E,$0E,$0E,$0E,$0E,$0E,$06,$06,$06,$06,$0B,$04,$04,$06,$06,$0E,$0E,$06,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E
58 | !byte $0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E
59 | !byte $0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$00,$00,$00,$00,$00,$00,$00,$00,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E
60 | !byte $0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$00,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E
61 |
--------------------------------------------------------------------------------
/docs/turbo56k.md:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 
5 |
6 |
7 |
8 | # Turbo56K v0.8
9 |
10 |
11 | **Turbo56K** was created by **Jorge Castillo** as a simple protocol to provide high speed file transfer functionality to his bit-banging `57600bps` **RS232** routine for the **Commodore 64**.
12 |
13 | Over time, the protocol has been extended to include `4-bit` **PCM** audio streaming, bitmap graphics transfer and display, **SID** and **PSG** music streaming and more.
14 |
15 | A typical **Turbo56K** command sequence consists of a command start character ( **CMDON** : `$FF` ) followed by the command itself (a character with it's 7th bit set) and the parameters it requires.
16 |
17 | The sequence ends with the command end character ( **CMDOFF** : `$FE` )
18 |
19 | Some commands will exit *command mode* automatically without needing a `CMDOFF` character, but is good practice to include it anyway.
20 |
21 | For example the following byte sequence enters command mode, sets the screen to Hires mode on page 0 with blue border and then exits command mode:
22 |
23 | $FF $90 $00 $06 $FE
24 |
25 |
26 | ---
27 |
28 |
29 |
30 | ## Reserved Characters
31 |
32 | | Hex | Dec | Description
33 | |:---:|:---:|------------
34 | | `$FF` | `255` |Enters command node
35 | | `$FE` | `254` |Exits command node
36 |
37 |
38 |
39 | ## Commands
40 |
41 |
42 |
43 | ### Data Transfer
44 |
45 | | Hex | Dec | Description
46 | |:---:|:---:|------------
47 | | `$80` | `128` | Sets the memory pointer for the next transfer **Parameters**
- Destination Address : 2 bytes : low \| high
48 | | `$81` | `129` | Selects preset address for the next transfer
**Parameters**
- Preset Number : 1 byte
49 | | `$82` | `130` | Start a memory transfer
**Parameters**
- Transfer Size : 2 bytes : low \| high
50 | | `$83` | `131` | Starts audio streaming until receiving a `$00` character
51 | | `$84` | `132` | Starts chiptune streaming until receiving a data block with size `0`, or interrupted by the user
52 | | `$85` | `133` | `New v0.6`
Sets the stream and write order of the registers for SID streaming
**Parameters**
- Stream : 25 bytes
53 | | `$86` | `134` | `New v0.7`
Starts a file transfer (to be saved on a storage device client side)
54 |
55 |
56 |
57 | ### Graphics Mode
58 |
59 | | Hex | Dec | Description
60 | |:---:|:---:|------------
61 | | `$90` | `144` | Returns to the default text mode
**Parameters**
- Page Number : 1 byte
- Border Color : 1 byte
- Background Color : 1 byte
62 | | `$91` | `145` | Switches to hi-res bitmap mode
**Parameters**
- Page Number : 1 byte
- Border Color : 1 byte
63 | | `$92` | `146` | Switches to multicolor bitmap mode
**Parameters**
- Page Number : 1 byte
- Border Color : 1 byte
- Background Color : 1 byte
**Only for Plus/4:**
- Multicolor 3 color : 1 byte
64 |
65 |
66 |
67 | ### Drawing Primitives
68 |
69 | | Hex | Dec | Description
70 | |:---:|:---:|------------
71 | | `$98` | `152` | `New v0.8` Clears graphic screen
72 | | `$99` | `153` | `New v0.8` Set pen color
**Parameters**
- Pen Number: 1 byte
- Color index: 1 byte
73 | | `$9A` | `154` | `New v0.8` Plot point
**Parameters**
- Pen Number: 1 byte
- X coordinate: 2 bytes
- Y coordinate: 2 bytes
74 | | `$9B` | `155` | `New v0.8` Line
**Parameters**
- Pen Number: 1 byte
- X1: 2 bytes
- Y1: 2 bytes
- X2: 2 bytes
- Y2: 2 bytes
75 | | `$9C` | `156` | `New v0.8` Box
**Parameters**
- Pen Number: 1 byte
- X1: 2 bytes
- Y1: 2 bytes
- X2: 2 bytes
- Y2: 2 bytes
- Fill: 1 byte
76 | | `$9D` | `157` | `New v0.8` Circle/Ellipse
**Parameters**
- Pen Number: 1 byte
- X: 2 bytes
- Y: 2 bytes
- rX: 2 bytes
- rY: 2bytes
77 | | `$9E` | `158` | `New v0.8` Fill
**Parameters**
- Pen Number: 1 byte
- X: 2 bytes
- Y: 2 bytes
78 |
79 |
80 |
81 | ### Connection Management
82 |
83 | | Hex | Dec | Description
84 | |:---:|:---:|------------
85 | | `$A0` | `160` | Selects the screen as the output for the received characters, exits command mode
86 | | `$A1` | `161` | Selects the optional hardware voice synthesizer as the output for the received characters, exits command mode.
(*Valid only for the microsint + rs232 / Wi-Fi board*)
87 | | `$A2` | `162` | Request terminal ID and version
88 | | `$A3` | `163` | `New v0.6`
Query if the command passed as parameter is implemented in the terminal. If the returned value has its 7th bit clear then the value is the number of parameters required by the command.
(*Max 8 in the current Retroterm implementation*)
If the 7th bit is set the command is not implemented.
89 | | `$A4` | `164` | `New v0.8`
Query the client's setup. The single byte parameter indicates which 'subsystem' is being queried. Client must reply with at least 1 byte indicating the reply length. Zero meaning not implemented. See below for the subsystem parameters.
90 |
91 |
92 |
93 | ### Screen Management
94 |
95 | | Hex | Dec | Description
96 | |:---:|:---:|------------
97 | | `$B0` | `176` | Moves the text cursor
**Parameters**
- Column : 1 byte
- Row : 1 byte
Exits command mode
98 | | `$B1` | `177` | Fills a text screen row with a given
character, text cursor is not moved
**Parameters**
- Screen Row : 1 byte
- Fill Character : 1 byte : *C64 Screen Code*
99 | | `$B2` | `178` | Enables or disables the text cursor
**Parameters**
- Enable : 1 byte
100 | | `$B3` | `179` | Screen split
**Parameters**
- Modes : 1 byte
`Bit 0 - 4` : Split Row `1 - 24`
`Bit 7` : Bitmap Graphics Mode in top section
`0` : Hires
`1` : Multicolor
- Background Color : 1 byte
`Bit 0 - 3` : Top Section
`Bit 4 - 7` : Bottom Section
101 | | `$B4` | `180` | `New v0.7`
Get text cursor position, returns 2 characters, column and row.
102 | | `$B5` | `181` | Set text window
**Parameters**
- Top Row : 1 byte : `0 - 23`
- Bottom Row : 1 byte : `1 - 24`
103 | | `$B6` | `182` | `New v0.7`
Scroll the text window up or down x rows
**Parameters**
- Row count: 1 byte -128/+127
104 | | `$B7` | `183` | `New v0.7`
Set ink color
**Parameters**
- Color index: 1 byte
105 |
106 |
107 | ### Preset Addresses
108 |
109 | *For command `$81`*
110 |
111 | #### Commodore 64 & Plus/4
112 | | Hex | Dec | Description
113 | |:---:|:---:|:------------
114 | | `$00` | `0` | Text page `0`
115 | | `$10` | `16` | Bitmap page `0`
116 | | `$20` | `32` | Color RAM
117 |
118 | *The current versions of **Retroterm** supports only a single text / bitmap page.*
*Values other than `0` for bits `0 - 3` will be ignored.*
119 |
120 | #### MSX1
121 |
122 | | Hex | Dec | Description
123 | |:---:|:---:|:------------
124 | | `$00` | `0` | Text/name table page `0`
125 | | `$10` | `16` | Pattern table page `0`
126 | | `$20` | `32` | Color table
127 |
128 | *Any other value will set the address to $4000 (RAM Page 1) -Subject to changes-*
129 |
130 | ### "Subsystems"
131 |
132 | *For command `$A4`*
133 |
134 | ##### `$00`: Platform/Refresh rate
135 |
136 | Reply length: 2 bytes
137 |
138 | | Position | Value
139 | |:---:|:---
140 | | 0 | 1
141 | | 1 | bits 0-6: platform
bit 7: Refresh rate
142 |
143 | ###### Platform:
144 |
145 | | Value | Platform
146 | |:---:|:---
147 | | 0 | C64
148 | | 1 | Plus/4
149 | | 2 | MSX
150 | | 3 | `reserved` C128
151 | | 4 | `reserved` VIC20
152 | | 5 | `reserved` ZX Spectrum
153 | | 6 | `reserved` Atari
154 | | 7 | `reserved` Apple II
155 | | 8 | `reserved` Amstrad
156 | | 9 | `reserved` Amiga
157 | | 10 | `reserved` PET
158 | |
159 |
160 | ###### Refresh rate:
161 |
162 | | Value | Meaning
163 | |:---:|:---
164 | | 0 | 50Hz
165 | | 1 | 60Hz
166 |
167 |
168 | ##### `$01`: Text screen size
169 |
170 | Reply length: 3 bytes
171 |
172 | | Position | Value
173 | |:---:|:---
174 | | 0 | 2
175 | | 1 | Columns
176 | | 2 | Rows
177 | |
178 |
179 | ##### `$02`: Connection speed
180 |
181 | Reply length: 2 bytes
182 |
183 | | Position | Value
184 | |:---:|:---
185 | | 0 | 1
186 | | 1 |
0: Network
1: 300bps
2: 600bps
3: 1200bps
4: 1800bps
5: 2400bps
6: 4800bps
7: 9600bps
8: 19200bps
9: 28800bps
10: 38400bps
11: 57600bps
12: 76800bps
13: 115200bps
187 | |
188 |
189 | ##### `$03`: RAM size
190 |
191 | Reply length: 3 bytes
192 |
193 | | Position | Value
194 | |:---:|:---
195 | | 0 | 2
196 | | 1-2 | RAM size in Kilobytes (little-endian)
197 | |
198 |
199 | ##### `$04`: VRAM size
200 |
201 | Reply length: 3 bytes
202 |
203 | | Position | Value
204 | |:---:|:---
205 | | 0 | 2
206 | | 1-2 | VRAM size in Kilobytes (little-endian)
207 | |
208 |
209 | ##### `$05`: Graphic modes (platform dependent)
210 |
211 | Reply length: 2 bytes
212 |
213 | | Position | Value
214 | |:---:|:---
215 | | 0 | 1
216 | | 1 | Graphic modes available
217 | |
218 |
219 | ###### C64:
220 |
221 | In addition to Hires and Multicolour
222 |
223 | | bit | Mode
224 | |:---:|:---
225 | | 0 | FLI
226 | | 1 | AFLI
227 | |
228 | ###### C128:
229 |
230 | In addition to Hires and Multicolour
231 |
232 | | bit | Mode
233 | |:---:|:---
234 | | 0 | FLI
235 | | 1 | AFLI
236 | | 2 | VDC
237 | | 3 | VDCI
238 |
239 | ###### MSX:
240 |
241 | In addition to Screen2
242 |
243 | | bit | Mode
244 | |:---:|:---
245 | | 0 | Screen 3
246 | | 1 | Screen 4
247 | | 2 | Screen 5
248 | | 3 | Screen 6
249 | | 4 | Screen 7
250 | | 5 | Screen 8
251 | | 6 | Screen 10
252 | | 7 | Screen 12
253 |
254 | ###### Amiga:
255 |
256 | | Value | Chipset
257 | |:---:|:---
258 | | 0 | OCS
259 | | 1 | ECS
260 | | 2 | AGA
261 |
262 | ##### `$06`: Audio (platform dependent)
263 |
264 | Reply length: 3 bytes
265 |
266 | | Position | Value
267 | |:---:|:---
268 | | 0 | 2
269 | | 1 | Synthesizers
270 | | 2 | PCM
271 |
272 | ###### Synthesizers
273 |
274 | ###### -Commodore 64/128
275 |
276 | | bit | Meaning
277 | |:---:|:---
278 | | 0-3 | Installed SID(s)-1
279 | | 4 | OPL present
280 | | 5 | microSynth present
281 | | 6 | Magic Voice present
282 |
283 | ###### -MSX
284 |
285 | | bit | Meaning
286 | |:---:|:---
287 | | 0 | MSX Audio present
288 | | 1 | MSX Music present
289 | | 2 | OPL3 present
290 |
291 | ###### PCM
292 |
293 | | bit | Meaning
294 | |:---:|:---
295 | | 0-1 | bits per sample (1(PWM)/4/8/16)
296 | | 2 | Channels (1/2)
297 | | 3 | Connection speed dependent sample rate
298 | | 4 | 11025Hz sample rate
299 | | 5 | 16000Hz sample rate
300 | | 6 | 22050Hz sample rate
301 | | 7 | Delta compression
302 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 | # Retroterm
4 | ### VERSION 0.30 Beta
5 |
6 | Jorge Castillo & Pablo Roldán
7 |
8 |
9 |     [](https://discord.gg/F2jmuUCBAG)
10 |
11 | ---
12 |
13 |
14 | ## Table of contents:
15 |
16 | 1. [Introduction](#1-introduction)
17 | 1. [Release history](#11-release-history)
18 | 2. [The *Turbo56K* protocol](#12-the-turbo56k-protocol)
19 | 3. [Features](#13-features)
20 | 4. [Requirements](#14-requirements)
21 | 2. [Usage](#2-usage)
22 | 3. [Building](#3-building-retroterm)
23 | 1. [Symbols](#31-symbols)
24 | 2. [Intro screen](#32-the-intro-screen)
25 | 3. [Customizing](#33-customizing)
26 | 4. [Known bugs](#4-known-bugs)
27 | 5. [To-do](#5-to-do)
28 | 6. [Acknowledgments](#6-acknowledgments)
29 |
30 | ---
31 |
32 |
33 | ## 1 Introduction
34 |
35 | *Retroterm* is a small, minimal *PETSCII* terminal for the *Commodore 64 / 128 (in 64 mode)*, *Commodore Plus/4* and *MSX1 (in development)*.
36 |
37 | **ATTENTION THE MSX PORT IS CURRENTLY IN ALPHA STATE**
38 |
39 | It implements the *[Turbo56k](docs/turbo56k.md)* protocol for high speed data transfer & streaming when connecting to a BBS supporting the protocol, such as [_RetroBBS_](https://github.com/retrocomputacion/retrobbs).
40 |
41 | Data rate is fixed at the following speeds:
42 |
43 | - 57600bps for Retroterm 64 for userport and Turbo232**
44 | - 57600bps for Retroterm MSX for parallel port (very alpha state - candidate for deprecation)
45 | - 38400bps for Retroterm 64 for Swiftlink**
46 | - 38400bps for Retroterm MSX for parallel port (alpha state - mostly stable)
47 | - 19200bps for Retroterm Plus/4** and Retroterm MSX for RS232**
48 |
49 | *(**)The full data throughput while using the turbo transfer / streaming can only be achieved with the screen disabled.*
50 |
51 | The effective throughput for text is *1500 / 1800bps* depending on *PAL/NTSC* timings respectively.
52 |
53 | *Retroterm* is optimized for use with **Wi-Fi** modems using the *Zimodem* firmware.
54 |
55 | *It also runs on the latest **VICE**/**Z64K** and **openMSX** emulators.*
56 |
57 | Separate *Commodore 64* versions of the executable are provided for cartridges featuring an ACIA 6551 such as *SwiftLink* (limited to **38400bps**) and *Turbo232*.
58 | The *Commodore Plus/4* version is limited to the maximum speed for the built in ACIA: **19200bps**
59 |
60 | The *MSX 1 RS-232* version (rt-msx-232.com) is also at this moment limited to **19200bps**, and only supports RS-232 interfaces that adhere to the MSX standard (ie: SVI-738 and HX-22 built-in ports, SVI-737 and Sony HB-232, or any other interface implemented with the i8251 + i8253 USART and Timer combo)
61 |
62 | ## 1.1 Release history
63 |
64 | ### v0.30 (??/??/2025):
65 | - Turbo56K v0.8 partial implementation
66 | - Drawing primitives: clear screen, plot, line, box, ellipse, fill
67 | - Commodore ports: Ability to save a configuration file to disk.
68 | Optional modem init string with selectable 300,1200 or 2400 baud speed.
69 | - Commodore ports: Phone book with up to 5 preset dial strings, also saved to the configuration file.
70 | - Bugfix, all ports: No more missing filename characters when downloading to disk
71 | - Bugfix, C64 ports: Fixed glitched sprites after downloading to disk
72 |
73 | ### v0.21 (Intermediate Github version, no oficial release):
74 | - New shortcut key for the Plus/4 port: `CBM+,` disables/enables the FLASH-ON control code. Improves compatibility with BBSs running Centipede 128 software.
75 | - Bugfix for the Commodore 64 ports: No more extraneous beep after streaming PCM audio.
76 |
77 | ### v0.20 (02/01/2024):
78 | - Turbo56K v0.7
79 | - New _Commodore Plus/4_ port. _Turbo56K v0.7_ commands implemented, except for the ones regarding SID tune streaming.
80 | - Fixed bug in command $A3 which caused the parameter to be misread, or the terminal to hang
81 | - New command `$86` to initiate a download to disk.
82 | - New command `$B6` to scroll the text window up or down X number of rows.
83 | - SID streaming now better supports tunes using _hardrestart_, a special version of _SIDdump_ and updated version of _RetroBBS_ is required.
84 | - New compile target `ultimate` compiles with timings compatible with the Swiftlink emulation in the Ultimate1541-II/II+ and Ultimate64.
85 | - Basic configuration screen by pressing `C= + F7`, terminal screen is not preserved.
86 | - ACIA based versions now allow selection of the interface base address ($DE00 or $DF00).
87 | - Connected disk drives are scanned on first run, and can be selected when downloading a file with command `$86`.
88 |
89 | ### v0.14 (13/04/2022):
90 | - Source code liberated
91 | - Turbo56K v0.6
92 | - Fixed small visual glitch when using the split screen mode
93 | - Better, more robust exit to BASIC
94 | - Disabled interrupts on command `$A2`, prevents crashes if (re)connecting to a BBS while the split screen mode is active
95 | - Fixed severe bug affecting the text output in early Commodore 64 Kernal revisions
96 | - Full digi-boost for 8580 SID
97 | - Intro screen exits automatically after ~2 seconds by default
98 | - Other small bugfixes.
99 | ### v0.13 (16/08/2021):
100 | - Initial release
101 | - Turbo56K v0.5
102 |
103 |
104 | ## 1.2 The Turbo56K protocol
105 | *[Turbo56k](docs/turbo56k.md)* was created by Jorge Castillo as a simple protocol to provide high-speed file transfer functionality to his bit-banging 57600bps RS232 routine for the C64.
106 | Over time, the protocol has been extended to include 4-bit PCM audio streaming, bitmap graphics transfer and display, SID music streaming and more.
107 |
108 | ## 1.3 Features
109 |
110 | *Implements all commands of the __[Turbo56k](docs/turbo56k.md)__ v0.7 protocol.*
111 |
112 | - Full duplex PETSCII (Commodore versions)/ASCII (MSX versions) color terminal
113 | - Turbo data transfers to custom/preset memory locations
114 | - Split Screen | Hi-res or Multicolor+Text
115 | - Up to 11520Hz 4-bit PCM audio streaming
116 | - Bitmap display | Hi-res + Multicolor (Commodore) | Screen 2 (MSX)
117 | - Uses 16K of RAM above $C000 (For the Commodore versions), the rest of the RAM is free to use as a buffer, load programs, graphics, etc.
118 | - 1x speed SID music streaming (C64 versions)
119 | - PSG music streaming (MSX versions)
120 | - Scrolling Text Windows
121 | - Set Cursor Position
122 | - Text Line Fill
123 | - Bidirectional scrolling
124 | - Download files to disk
125 | - Graphic primitives, draw onto Hi-res/Multicolor screens
126 |
127 | ## 1.4 Requirements
128 |
129 | - A Commodore 64, 128 or Plus/4 computer, or an emulator such as VICE or Z64K
130 | - Either an userport Wi-Fi modem with the Zimodem firmware or...
131 | - A *SwiftLink* or *Turbo232* compatible cartridge connected to a Wi-Fi modem with the Zimodem firmware.
132 | - A MSX1 or superior computer with 64K of RAM. With either a built-in RS-232 port or an MSX standard RS-232 interface cartridge. Or openMSX 20.0RC1
133 | - ACME and PASMO crossassemblers for building the programs.
134 |
135 | ## 2 Usage
136 | *Retroterm* is very simple to use, most of its functionality being controlled externally from a *[Turbo56k](docs/turbo56k.md)* enabled BBS.
137 |
138 | *Retroterm* comes in five variants:
139 |
140 | - **rt-cbm-u.prg** Userport version 57600bps
141 | - **rt-cbm-sl.prg** SwiftLink version 38400bps
142 | - **rt-cbm-232.prg** Turbo232 version 57600bps
143 | - **rt-cbm-p4.prg** Plus/4 version 19200bps
144 | - **rt-msx-232.com** MSX RS-232 version 19200bps
145 | - **rt-msx-38k.com** MSX parallel port version 38400bps
146 | - **rt-msx-56k.com** MSX parallel port version 57600bps
147 |
148 | *Retroterm* lacks classic file transfer functions, when used to communicate with a normal PETSCII/ASCII BBS, file transfers are not available.
149 |
150 | After LOADing and RUNning *Retroterm*, you can dial to your favorite BBS using your Modem commands as usual.
151 |
152 | **On C64 and Plus/4 ports, _Retroterm_ will search for a configuration file on the last used drive, if found, and a modem initialization string is set, it will be sent at this moment. If no configuration file is found then the setup screen will be shown**
153 |
154 | **The modem should be setup to the correct baud rate before running _Retroterm_.**
155 |
156 | To exit *Retroterm*, just press `RUN/STOP` (Commodore) or `CTRL-C` (MSX), it will remain in memory, and you can recall it with `SYS49152` (Commodore 64), or `SYS28672` (Commodore Plus/4).
157 |
158 | If you downloaded a program into memory from a BBS you can also `RUN` it (Commodore versions only).
159 |
160 | On MSX pressing `CTRL-U` will reset the computer, if a ROM file was downloaded to RAM the system will try to execute it. ROMs that expect mirroring are not supported.
161 |
162 | *Retroterm* beeps for every received character by default, you can toggle the sound by pressing `CBM + M` (Commodore) or `CTRL-W` (MSX).
163 |
164 | ## 2.1 Setup screen
165 |
166 | A simple setup screen can be accessed by pressing `CBM + F7` (Commodore) or `CTRL-F5` (MSX), pressing `F1` will exit back to the terminal.
167 |
168 | The first setting, common to all _Retroterm_ variants sets the **RTS** pulse width. Current values are known to work under VICE, or on real hardware with an userport modem using Zimodem firmware, and with the Ultimate Swiftlink emulation.
169 | Use the `+` and `-` keys to adjust.
170 |
171 | For the ACIA versions there's a couple more settings.
172 |
173 | The first one sets the base address for the Swiftlink or Turbo232 cartridge, press `1` for $D700 or `2` for $DE00 or `3` for $DF00. Switching addresses will drop any current connection.
174 |
175 | The second setting available for ACIA versions is the ability to keep the screen visible while transferring at turbo speeds. Turbo transfers are slightly slower with the screen enabled. Press `B` to toggle.
176 |
177 | For C64 and Plus/4 ports, an optional modem initialization string can be edited by pressing `I`. The baud rate used to transmit this string can be set by pressing `R`, with current options being `SKIP`, `300`, `1200` and `2400`.
178 | This string is only transmitted when running _Retroterm_ with `RUN`, automatically if a configuration file is found, or, if no file is found by selecting the appropriate options in the setup screen before exiting to the terminal.
179 | Use `F5` to save the current settings to disk.
180 |
181 | Finally pressing `P` switches to the phone book screen, here you can select one of 5 preset dial strings and either `E`dit or `D`ial it.
182 | (Dialing only works once _Retroterm_ has been initialized properly, meaning only when accessing the setup screen from within the terminal mode)
183 |
184 |
185 | **Important**: Upon exiting the setup screen, _Retroterm_ will default to full screen text mode. Only previous background and border colors will be restored.
186 |
187 | ## 3 Building Retroterm
188 | The Commodore versions of *Retroterm* is written for the *ACME* cross-assembler, while *PASMO* is used for the MSX port.
189 |
190 | Exomizer is used to pack all the Commodore ports. Find these packed versions inside the `/build/packed/` subdirectory
191 |
192 | To compile use:
193 |
194 | ```
195 | make all
196 | ```
197 | to compile all versions.
198 |
199 | For all Commodore versions use
200 | ```
201 | make cbm
202 | ```
203 |
204 | For all MSX versions use
205 | ```
206 | make msx
207 | ```
208 |
209 | Or you can specify which version you want to compile, either `userport`, `swiflink`, `turbo232`, `plus4`, `msx232`, `msx56k` or `msx38k`.
210 |
211 | ie:
212 | ```
213 | make userport
214 | ```
215 | All executables will be stored in the `build` directory.
216 |
217 | You can also manually compile with:
218 | ```
219 | acme retroterm_univ.asm
220 | ```
221 |
222 | or:
223 | ```
224 | pasmo -E IFACE=0 retrotermm1.asm rt-msx-232.com
225 | pasmo -E IFACE=56 retrotermmm1.asm rt-msx-56k.com
226 | ```
227 |
228 | from the `source` directory.
229 | This will compile the default userport version of *Retroterm* with an intro screen that last a couple of seconds. In this case the resulting executable will be written to the `source` directory
230 |
231 | ## 3.1 Symbols
232 | A number of compile time symbols are defined to customize the resulting executable. Specially if you're running the compiler directly instead of using the Makefile
233 |
234 | ### `_HARDTYPE_`:
235 | `38`: Compile for *SwiftLink/Turbo232* cartridges at **38400bps**
236 |
237 | `56`: Compile for userport at **57600bps** -- **_Default_**
238 |
239 | `232`: Compile for *Turbo232* cartridges at **57600bps**
240 |
241 | `1541`: Compile for the *Ultimate 1541-II* or *Ultimate 64* Swiftlink emulation, same code as for `38` but different timing.
242 |
243 | ### `_INTRO_`:
244 | `0`: No intro screen
245 |
246 | `1`: Include the intro screen -- **_Default_**
247 |
248 | ### `_SPACE_`:
249 | If defined wait for the user to press the space bar at the intro screen. Otherwise, the intro screen only last a couple of seconds.
250 |
251 | **_Not defined by default_**
252 |
253 | ### `IFACE`:
254 | `0`: Compile for standard MSX RS232 ports
255 | `56`: Compile for the MSX parallel port
256 |
257 | ### Example:
258 |
259 | ```
260 | acme -D_HARDTYPE_=232 -D_INTRO_=0 retroterm_univ.asm
261 | ```
262 | Compiles _Retroterm_ for the _Turbo232_ cartridge with no intro screen.
263 |
264 | ## 3.2 The intro screen
265 | The intro screen is a `screencode + colorRAM` dump found in `source/intro_sc.asm`
266 |
267 | This file is generated by exporting `source/intro_sc.petmate` to ACME format from [Petmate](https://nurpax.github.io/petmate/).
268 |
269 | ## 3.3 Customizing
270 |
271 | If you want to release a modified version of _Retroterm_ which differs in functionality from the official release we recommend you use a custom _ID string_, respecting the maximum 22 character length and always starting in uppercase `RT`
272 |
273 | IE, the normal ID string is:
274 | ```
275 | IDstring:
276 | !text "RTRETROTERM 0.20 "
277 | ```
278 | but the string when compiling for the *SwiftLink* cartridge is:
279 |
280 | ```
281 | IDstring:
282 | !text "RTRETROTERM-SL 0.20 "
283 | ```
284 |
285 | **Note: The actual version number string is sourced from the file `source/version.txt` when using the *makefile*, or from `source/version.asm` when running the compiler directly**
286 |
287 |
288 | For compatibility reasons we ask you not to modify the behavior of existing Turbo56K commands, but you're welcomed to add new commands, or remove unwanted ones, as long as command `$A3` correctly reports the existence or not of all queried commands.
289 |
290 | In any case the *[Turbo56k](docs/turbo56k.md)* version bytes that follow the ID string should remain the correct ones for the official version your modified code support.
291 |
292 |
293 | ## 4 Known bugs/Issues
294 |
295 | - All versions: Losing connection while streaming data or audio will hang the program
296 | - Commodore 64 versions: Exiting `Retroterm`, restarting it with `SYS49152`, exiting again and causing a BASIC error will crash the computer.
297 | - Commodore Plus/4 version: `Retroterm` will crash if loaded from the file browser included in _Joco's C264 SD drive cartridge_. Loading from BASIC using the @ commands works fine.
298 |
299 | ## 5 To-do
300 | - Extend the command parameter space to support more than 8 parameters per command.
301 | - Faster throughput when using any of the ACIA cartridges.
302 |
303 | ## 6 Acknowledgments
304 | ### Beta Testers
305 |
306 | - **Ezequiel Filgueiras**
307 | - **Thierry Kurt**
308 | - **Diego di Franceschi**
309 | - **ChrisKewl**
310 | - **Roberto Mandracchia**
311 | - **x1pepe**
312 |
313 | ### Thanks To
314 |
315 | - **Willy Manilly** for adding support to the *Z64K emulator*
316 |
317 | - [**ElectronicsArchiver**](https://github.com/ElectronicsArchiver) for initial documentation rework
318 |
319 | - [**idolpx**](https://github.com/idolpx) for improved Makefile
--------------------------------------------------------------------------------
/source/intro_sc.petmate:
--------------------------------------------------------------------------------
1 | {"version":2,"screens":[0],"framebufs":[{"width":40,"height":25,"backgroundColor":1,"borderColor":1,"borderOn":false,"charset":"lower","name":"screen_001","framebuf":[[{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14}],[{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14}],[{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14}],[{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14}],[{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14}],[{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14}],[{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14}],[{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":0},{"code":32,"color":0},{"code":32,"color":0},{"code":32,"color":0},{"code":32,"color":0},{"code":32,"color":0},{"code":32,"color":0},{"code":32,"color":0},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":225,"color":0},{"code":32,"color":0},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":0},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14}],[{"code":32,"color":14},{"code":124,"color":2},{"code":226,"color":2},{"code":226,"color":2},{"code":226,"color":2},{"code":226,"color":2},{"code":226,"color":2},{"code":226,"color":2},{"code":226,"color":2},{"code":226,"color":2},{"code":126,"color":2},{"code":255,"color":0},{"code":226,"color":0},{"code":226,"color":0},{"code":108,"color":0},{"code":226,"color":0},{"code":226,"color":0},{"code":127,"color":0},{"code":124,"color":0},{"code":251,"color":0},{"code":226,"color":0},{"code":108,"color":0},{"code":226,"color":0},{"code":226,"color":0},{"code":126,"color":0},{"code":255,"color":0},{"code":226,"color":0},{"code":226,"color":0},{"code":123,"color":0},{"code":226,"color":2},{"code":226,"color":2},{"code":226,"color":2},{"code":226,"color":2},{"code":226,"color":2},{"code":226,"color":2},{"code":226,"color":2},{"code":226,"color":2},{"code":226,"color":2},{"code":126,"color":2},{"code":32,"color":14}],[{"code":124,"color":7},{"code":226,"color":7},{"code":226,"color":7},{"code":226,"color":7},{"code":226,"color":7},{"code":226,"color":7},{"code":226,"color":7},{"code":226,"color":7},{"code":226,"color":7},{"code":226,"color":7},{"code":126,"color":7},{"code":97,"color":0},{"code":32,"color":14},{"code":32,"color":14},{"code":225,"color":0},{"code":226,"color":0},{"code":226,"color":0},{"code":226,"color":0},{"code":32,"color":2},{"code":225,"color":0},{"code":32,"color":0},{"code":225,"color":0},{"code":32,"color":0},{"code":32,"color":14},{"code":32,"color":14},{"code":97,"color":0},{"code":32,"color":14},{"code":32,"color":0},{"code":97,"color":0},{"code":226,"color":7},{"code":226,"color":7},{"code":226,"color":7},{"code":226,"color":7},{"code":226,"color":7},{"code":226,"color":7},{"code":226,"color":7},{"code":226,"color":7},{"code":226,"color":7},{"code":226,"color":7},{"code":126,"color":7}],[{"code":124,"color":13},{"code":226,"color":13},{"code":226,"color":13},{"code":226,"color":13},{"code":226,"color":13},{"code":226,"color":13},{"code":226,"color":13},{"code":226,"color":13},{"code":226,"color":13},{"code":226,"color":13},{"code":126,"color":13},{"code":126,"color":0},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":226,"color":0},{"code":226,"color":0},{"code":226,"color":0},{"code":32,"color":2},{"code":32,"color":14},{"code":226,"color":0},{"code":124,"color":0},{"code":32,"color":0},{"code":32,"color":14},{"code":32,"color":14},{"code":124,"color":0},{"code":226,"color":0},{"code":226,"color":0},{"code":32,"color":2},{"code":226,"color":13},{"code":226,"color":13},{"code":226,"color":13},{"code":226,"color":13},{"code":226,"color":13},{"code":226,"color":13},{"code":226,"color":13},{"code":226,"color":13},{"code":226,"color":13},{"code":226,"color":13},{"code":126,"color":13}],[{"code":32,"color":14},{"code":124,"color":14},{"code":226,"color":14},{"code":226,"color":14},{"code":226,"color":14},{"code":226,"color":14},{"code":226,"color":14},{"code":226,"color":14},{"code":226,"color":14},{"code":226,"color":14},{"code":126,"color":14},{"code":226,"color":14},{"code":226,"color":14},{"code":226,"color":14},{"code":124,"color":14},{"code":226,"color":14},{"code":226,"color":14},{"code":226,"color":14},{"code":124,"color":14},{"code":226,"color":14},{"code":226,"color":14},{"code":124,"color":14},{"code":226,"color":14},{"code":226,"color":14},{"code":126,"color":14},{"code":226,"color":14},{"code":226,"color":14},{"code":226,"color":14},{"code":126,"color":14},{"code":226,"color":14},{"code":226,"color":14},{"code":226,"color":14},{"code":226,"color":14},{"code":226,"color":14},{"code":226,"color":14},{"code":226,"color":14},{"code":226,"color":14},{"code":226,"color":14},{"code":126,"color":14},{"code":32,"color":14}],[{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":225,"color":0},{"code":32,"color":0},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":0},{"code":124,"color":0},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14}],[{"code":108,"color":0},{"code":226,"color":0},{"code":226,"color":0},{"code":226,"color":0},{"code":108,"color":0},{"code":226,"color":0},{"code":226,"color":0},{"code":127,"color":0},{"code":225,"color":0},{"code":226,"color":0},{"code":236,"color":0},{"code":127,"color":0},{"code":225,"color":0},{"code":226,"color":0},{"code":226,"color":0},{"code":127,"color":0},{"code":225,"color":0},{"code":32,"color":14},{"code":32,"color":14},{"code":225,"color":0},{"code":124,"color":0},{"code":251,"color":0},{"code":226,"color":0},{"code":32,"color":0},{"code":226,"color":0},{"code":226,"color":0},{"code":127,"color":0},{"code":108,"color":0},{"code":226,"color":0},{"code":226,"color":0},{"code":226,"color":0},{"code":225,"color":0},{"code":108,"color":0},{"code":226,"color":0},{"code":226,"color":0},{"code":127,"color":0},{"code":225,"color":0},{"code":226,"color":0},{"code":226,"color":0},{"code":123,"color":0}],[{"code":225,"color":0},{"code":32,"color":0},{"code":32,"color":14},{"code":32,"color":0},{"code":225,"color":0},{"code":32,"color":14},{"code":32,"color":14},{"code":225,"color":0},{"code":225,"color":0},{"code":32,"color":0},{"code":97,"color":0},{"code":225,"color":0},{"code":225,"color":0},{"code":32,"color":0},{"code":32,"color":0},{"code":225,"color":0},{"code":225,"color":0},{"code":32,"color":14},{"code":32,"color":14},{"code":225,"color":0},{"code":32,"color":2},{"code":225,"color":0},{"code":32,"color":0},{"code":108,"color":0},{"code":226,"color":0},{"code":226,"color":0},{"code":251,"color":0},{"code":225,"color":0},{"code":32,"color":0},{"code":32,"color":14},{"code":32,"color":0},{"code":225,"color":0},{"code":225,"color":0},{"code":32,"color":14},{"code":32,"color":14},{"code":225,"color":0},{"code":225,"color":0},{"code":32,"color":0},{"code":32,"color":14},{"code":97,"color":0}],[{"code":32,"color":14},{"code":226,"color":0},{"code":226,"color":0},{"code":226,"color":0},{"code":32,"color":14},{"code":226,"color":0},{"code":226,"color":0},{"code":126,"color":0},{"code":124,"color":0},{"code":32,"color":0},{"code":126,"color":0},{"code":124,"color":0},{"code":225,"color":0},{"code":226,"color":0},{"code":226,"color":0},{"code":126,"color":0},{"code":32,"color":14},{"code":226,"color":0},{"code":226,"color":0},{"code":126,"color":0},{"code":32,"color":2},{"code":32,"color":14},{"code":226,"color":0},{"code":32,"color":0},{"code":226,"color":0},{"code":226,"color":0},{"code":226,"color":0},{"code":32,"color":14},{"code":226,"color":0},{"code":226,"color":0},{"code":226,"color":0},{"code":124,"color":0},{"code":32,"color":14},{"code":226,"color":0},{"code":226,"color":0},{"code":126,"color":0},{"code":124,"color":0},{"code":32,"color":0},{"code":32,"color":14},{"code":126,"color":0}],[{"code":124,"color":14},{"code":226,"color":14},{"code":226,"color":14},{"code":226,"color":14},{"code":124,"color":14},{"code":226,"color":14},{"code":226,"color":14},{"code":226,"color":14},{"code":124,"color":14},{"code":226,"color":14},{"code":226,"color":14},{"code":226,"color":14},{"code":124,"color":0},{"code":124,"color":14},{"code":226,"color":14},{"code":226,"color":14},{"code":124,"color":14},{"code":226,"color":14},{"code":226,"color":14},{"code":226,"color":14},{"code":124,"color":14},{"code":226,"color":14},{"code":226,"color":14},{"code":124,"color":14},{"code":226,"color":14},{"code":226,"color":14},{"code":226,"color":14},{"code":124,"color":14},{"code":226,"color":14},{"code":226,"color":14},{"code":226,"color":14},{"code":124,"color":14},{"code":124,"color":14},{"code":226,"color":14},{"code":226,"color":14},{"code":226,"color":14},{"code":124,"color":14},{"code":226,"color":14},{"code":226,"color":14},{"code":126,"color":14}],[{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14}],[{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14}],[{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":82,"color":6},{"code":69,"color":6},{"code":84,"color":6},{"code":82,"color":6},{"code":79,"color":6},{"code":67,"color":6},{"code":79,"color":6},{"code":77,"color":6},{"code":80,"color":6},{"code":85,"color":6},{"code":84,"color":6},{"code":65,"color":6},{"code":67,"color":6},{"code":73,"color":6},{"code":79,"color":6},{"code":78,"color":6},{"code":46,"color":6},{"code":67,"color":6},{"code":79,"color":6},{"code":77,"color":6},{"code":32,"color":6},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14}],[{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":6},{"code":32,"color":6},{"code":32,"color":6},{"code":16,"color":6},{"code":18,"color":6},{"code":5,"color":6},{"code":19,"color":6},{"code":5,"color":6},{"code":14,"color":6},{"code":20,"color":6},{"code":1,"color":6},{"code":32,"color":6},{"code":32,"color":6},{"code":32,"color":6},{"code":32,"color":6},{"code":32,"color":6},{"code":32,"color":6},{"code":32,"color":6},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14}],[{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":6},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":6},{"code":32,"color":6},{"code":32,"color":6},{"code":32,"color":6},{"code":32,"color":11},{"code":32,"color":4},{"code":32,"color":4},{"code":32,"color":6},{"code":32,"color":6},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":6},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14}],[{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":82,"color":0},{"code":5,"color":0},{"code":20,"color":0},{"code":18,"color":0},{"code":15,"color":0},{"code":20,"color":0},{"code":5,"color":0},{"code":18,"color":0},{"code":13,"color":0},{"code":32,"color":0},{"code":32,"color":0},{"code":32,"color":0},{"code":32,"color":0},{"code":32,"color":0},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14}],[{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":0},{"code":32,"color":0},{"code":32,"color":0},{"code":32,"color":0},{"code":32,"color":0},{"code":32,"color":0},{"code":32,"color":0},{"code":32,"color":0},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14}],[{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":0},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14},{"code":32,"color":14}]],"zoom":{"zoomLevel":101,"alignment":"left"}}],"customFonts":{}}
--------------------------------------------------------------------------------
/source/retrotermp4.asm:
--------------------------------------------------------------------------------
1 | ;////////////////////////////////////////////////////////////////////////////////////////////
2 | ; BBS PETSCII compatible terminal, RS232 with tcpser/BBSServer or wifi with zimodem firmware
3 | ; Supports TURBO56K v0.7 protocol at 19200 bps, using TX, RX and RTS
4 | ;////////////////////////////////////////////////////////////////////////////////////////////
5 | ;
6 | ; Constants
7 |
8 | STROUT = $9088 ; BASIC String out routine
9 | CHROUT = $FFD2 ; Kernal CHROUT (prints a single character)
10 | STOP = $FFE1 ; Kernal STOP (checks STOP key)
11 | GETIN = $FFE4 ; Kernal GETIN
12 | PLOT = $FFF0 ; Kernal PLOT
13 | CHKIN = $FFC6 ; Kernal CHKIN
14 | READST = $FFB7 ; Kernal READST
15 | CHRIN = $FFCF ; Kernal CHRIN
16 | LISTEN = $FFB1 ; Kernal LISTEN
17 | SECLSN = $FF93 ; Kernal SECLSN
18 | UNLSN = $FFAE ; Kernal UNLSN
19 | SETNAM = $FFBD ; Kernal SETNAM
20 | SETLFS = $FFBA ; Kernal SETLFS
21 | KOPEN = $FFC0 ; Kernal OPEN
22 | KCLOSE = $FFC3 ; Kernal CLOSE
23 | CHKOUT = $FFC9 ; Kernal CHKOUT
24 | CLRCHN = $FFCC ; Kernal CLRCHN
25 |
26 | COLORMEM = $0800 ; Character Colors
27 |
28 | CURRLINEPTR = $C8 ; Current text line pointer (zero page)
29 | CURRLINE = $CD
30 | CURRCOLUMN = $CA ; Current column (zero page)
31 | CURRCOLLINE = $EA ; Current text line color porinter (zero page)
32 | ACIABASE = $FD00 ; ACIA 6551 base address
33 | ACIADATA = ACIABASE+0 ; Registro de datos del ACIA 6551
34 | ACIASTATUS = ACIABASE+1 ; Registro de estado del ACIA 6551
35 | ACIACOMMAND = ACIABASE+2; Registro de comando del ACIA 6551
36 | ACIACONTROL = ACIABASE+3; Registro de control del ACIA 6551
37 | BEEPTIME = 4 ; Cantidad minima de cuadros que dura un beep de impresion
38 | PrBuffer = ENDOFCODE ; Buffer de impresion
39 |
40 | MAXCMD = $B7 ; Highest command implemented
41 |
42 | !ifndef _MAKE_{
43 | !to "rt_p4_v0.20.prg", cbm
44 | !sl "labels-p4.txt"
45 | }
46 |
47 |
48 | ;///////////////////////////////////////////////////////////////////////////////////
49 | ; MACROSS
50 | ;///////////////////////////////////////////////////////////////////////////////////
51 | !macro SetCursor .col, .row {
52 | CLC
53 | LDY #.col
54 | LDX #.row
55 | JSR PLOT
56 | }
57 |
58 | !macro StringOut .addr {
59 | LDA #<.addr
60 | LDY #>.addr
61 | JSR STROUT
62 | }
63 |
64 | !macro DisROMs {
65 | STA $FF3F
66 | }
67 |
68 | !macro EnROMs {
69 | STA $FF3E
70 | }
71 |
72 | !macro _Version_{ ; Insert version number string
73 | !src "version.asm"
74 | }
75 |
76 | *= $1001
77 |
78 | ;///////////////////////////////////////////////////////////////////////////////////
79 | ; BASIC Header
80 | ;///////////////////////////////////////////////////////////////////////////////////
81 |
82 | !byte $0C, $10, $E4, $07, $9E, $20, $34, $31, $31, $32, $00 ; 10 SYS 4112
83 | !byte $00, $00
84 |
85 | *= $1010
86 |
87 | ;////////////////////////////////////////////////////////////////////////////////////////////
88 | ; Start (4110)
89 | ;////////////////////////////////////////////////////////////////////////////////////////////
90 |
91 | _Start:
92 |
93 | LDX #$11
94 | .c0 LDY #$08 ;<-
95 | .c2 LDA _DATA2,X ;<-
96 | ;BEQ .c1
97 | STA $0058,Y
98 | .c1 DEX ;<-
99 | DEY
100 | BPL .c2
101 | TXA
102 | PHA
103 | TYA
104 | PHA
105 | JSR $88C7 ; >>Open space in memory
106 | PLA
107 | TAY
108 | PLA
109 | TAX
110 | BPL .c0
111 |
112 | LDA #113 ; White screen and border
113 | STA $FF15
114 | STA $FF19
115 |
116 | LDA #
InitScr
118 | JSR STROUT ;PrintTxt
119 |
120 | ; Copy LogoScr to 3352 ($0D18)
121 | LDX #200
122 | - LDA LogoScr-1,X
123 | STA $0D18-1,X
124 | LDA LogoScr+200-1,X
125 | STA $0D18+200-1,X
126 | DEX
127 | BNE -
128 | ; Copy LogoClr to 2328 ($0918)
129 | LDX #200
130 | - LDA LogoClr-1,X
131 | STA $0918-1,X
132 | LDA LogoClr+200-1,X
133 | STA $0918+200-1,X
134 | DEX
135 | BNE -
136 |
137 | ; Print retrocomputacion URL
138 |
139 | JSR InitPalette ; Needed because exomizer scrambles the system palette table
140 |
141 | CLC ; Set the cursor to row 20, column 4
142 | LDX #20
143 | LDY #4
144 | JSR PLOT
145 | LDA #RetroIntro
147 | JSR STROUT
148 | LDA #$81
149 | STA $A5
150 | - LDA $A5
151 | BNE -
152 |
153 | LDA $AE
154 | STA load_drive
155 |
156 | JSR DrvDetect
157 |
158 | LDA $FF07
159 | ASL
160 | AND #$80
161 | +DisROMs
162 | ORA _sub0+1
163 | STA _sub0+1 ; Set refresh rate
164 | +EnROMs
165 |
166 | LDX #$07
167 | - LDA FTable,X
168 | STA $0567,X
169 | LDA #$01
170 | STA $055F,X
171 | DEX
172 | BPL -
173 |
174 | JSR earlysetup
175 | JMP CODESTART
176 |
177 | ;Detect present drives for devices 8-15
178 | DrvDetect:
179 | -- JSR chdrive
180 | LDA result
181 | BEQ ++ ; Not found? continue with next device
182 | LDA #IDQTY
183 | STA IDtmp
184 | - LDA IDtmp
185 | ASL
186 | TAY
187 | LDA IDptr,Y
188 | LDX IDptr+1,Y
189 | JSR cmpstr
190 | BPL + ;If found ->
191 | DEC IDtmp ;not found, try next ID string
192 | BPL -
193 | ; found or out of ID strings
194 | + LDA device
195 | SEC
196 | SBC #$08
197 | TAX
198 | LDA IDtmp
199 | STA DRVlst,X
200 |
201 | ++ INC device
202 | LDA #$10
203 | CMP device
204 | BNE --
205 |
206 | ;Copy drive list
207 | SEI
208 | +DisROMs
209 | LDX #$07
210 | - LDA DRVlst,X
211 | STA DRIVES,X
212 | DEX
213 | BPL -
214 | +EnROMs
215 | CLI
216 | RTS
217 |
218 | chdrive:
219 | ;first check if device present
220 | LDA #$00
221 | STA $90 ; clear STATUS flags
222 |
223 | LDA device ; device number
224 | JSR LISTEN ; call LISTEN
225 | LDA #$6F ; secondary address 15 (command channel)
226 | JSR SECLSN ; call SECLSN (SECOND)
227 | JSR UNLSN ; call UNLSN
228 | LDA $90 ; get STATUS flags
229 | BNE .devnp ; device not present
230 |
231 | LDA #cmd_end-cmd
232 | LDX #cmd
234 | JSR SETNAM ; call SETNAM
235 |
236 | LDA #$0F ; file number 15
237 | LDX device ; last used device number
238 | BNE +
239 | LDX #$08 ; default to device 8
240 | + LDY #$0F ; secondary address 15
241 | JSR SETLFS ; call SETLFS
242 |
243 | JSR KOPEN ; call OPEN
244 | BCS ++ ; if carry set, the file could not be opened
245 | LDX #$0F ; filenumber 15
246 | JSR CHKIN ; CHKIN file now used as input
247 | LDY #$03
248 | - JSR READST ; call READST (read status byte)
249 | BNE + ; either EOF or read error
250 | JSR CHRIN ; call CHRIN (get a byte from file)
251 | DEY ; skip first 3 chars
252 | BNE -
253 | - JSR READST ; call READST
254 | BNE +
255 | JSR CHRIN ; call CHRIN
256 | STA result,Y
257 | INY
258 | JMP - ; next byte
259 | +
260 | - LDA #$00
261 | STA result,Y ; Null terminate result string
262 | LDA #$0F
263 | JSR KCLOSE ; call CLOSE
264 |
265 | JMP CLRCHN ; call CLRCHN
266 | ; RTS
267 | ++
268 | ;... error handling for open errors ...
269 | LDY #$00
270 | BEQ - ; even if OPEN failed, the file has to be closed
271 | .devnp
272 | LDY #$00
273 | STY result ; 'clear' result string
274 | RTS
275 |
276 | cmpstr: ;Find substring, ID string addr in .a/.x. Return .x :$00 if found, $FF otherwise
277 | STA $D8
278 | STX $D9
279 | LDX #$FF
280 | STX match
281 | ; Iterate ID string until finding the 1st character of the substing
282 | LDY #$FF
283 | -- INY
284 | - INX
285 | LDA ($D8),Y
286 | BEQ ++ ; If null, exit
287 | CMP result,X
288 | BNE +
289 | ; match
290 | LDA #$00
291 | STA match
292 | BEQ -- ; continue with the next character in both strings
293 | ; no match
294 | + LDA #$FF
295 | STA match
296 | LDA result,X
297 | BEQ ++ ; end of ID string?
298 | LDY #$00 ; reset substring index
299 | BEQ -
300 | ++ LDX match
301 | RTS
302 |
303 |
304 | device: !byte $08
305 | cmd: !text "UI",$0d ; command string
306 | cmd_end:
307 | match !byte $ff ; string matched $00 or not $ff
308 |
309 | result: !fill $40, $00 ; Drive response tmp string
310 | DRVlst: !fill $08, $ff ; Available Drive list ($FF = not found)
311 | ; Expected ID substrings
312 | ID1541: !text "1541",$00 ; #ID 10
313 | ID1551: !text "TDISK",$00 ; #ID 9
314 | ID1570: !text "1570",$00 ; #ID 8
315 | ID1571: !text "1571",$00 ; #ID 7
316 | ID1581: !text "1581",$00 ; #ID 6
317 | IDCMDFD: !text "CMD FD",$00 ; #ID 5
318 | IDSD2IEC: !text "SD2IEC",$00 ; #ID 4
319 | IDULTI: !text "ULTIMATE",$00 ; #ID 3
320 | IDVICEFS: !text "VICE",$00 ; #ID 2
321 | IDVICE: !text "VIRTUAL",$00 ; #ID 1
322 | IDPI1541: !text "PI1541",$00 ; #ID 0
323 |
324 | IDQTY = 11-1
325 |
326 | IDptr: !word IDPI1541,IDVICE,IDVICEFS,IDULTI, IDSD2IEC, IDCMDFD, ID1581, ID1571, ID1570, ID1551, ID1541
327 | IDtmp: !byte IDQTY
328 |
329 | _DATA2:
330 | !word ENDOFCODE, _ENDOFCODE_
331 | !byte $00, $00, $00
332 | !word _CODESTART_
333 |
334 | !word ENDSHADOW, _ENDSHADOW_
335 | !byte $00, $00, $00
336 | !word _SHADOWCODE_
337 |
338 | ;///////////////////////////////////////////////////////////////////////////////////
339 | ; Retrocomputacion logo
340 |
341 | LogoScr
342 | !byte 32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,225,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32
343 | !byte 32,124,226,226,226,226,226,226,226,226,126,255,226,226,108,226,226,127,124,251,226,108,226,226,126,255,226,226,123,226,226,226,226,226,226,226,226,226,126,32
344 | !byte 124,226,226,226,226,226,226,226,226,226,126,97,32,32,225,226,226,226,32,225,32,225,32,32,32,97,32,32,97,226,226,226,226,226,226,226,226,226,226,126
345 | !byte 124,226,226,226,226,226,226,226,226,226,126,126,32,32,32,226,226,226,32,32,226,124,32,32,32,124,226,226,32,226,226,226,226,226,226,226,226,226,226,126
346 | !byte 32,124,226,226,226,226,226,226,226,226,126,226,226,226,124,226,226,226,124,226,226,124,226,226,126,226,226,226,126,226,226,226,226,226,226,226,226,226,126,32
347 | !byte 32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,225,32,32,32,32,32,32,32,32,32,124,32,32,32,32,32,32,32,32
348 | !byte 108,226,226,226,108,226,226,127,225,226,236,127,225,226,226,127,225,32,32,225,124,251,226,32,226,226,127,108,226,226,226,225,108,226,226,127,225,226,226,123
349 | !byte 225,32,32,32,225,32,32,225,225,32,97,225,225,32,32,225,225,32,32,225,32,225,32,108,226,226,251,225,32,32,32,225,225,32,32,225,225,32,32,97
350 | !byte 32,226,226,226,32,226,226,126,124,32,126,124,225,226,226,126,32,226,226,126,32,32,226,32,226,226,226,32,226,226,226,124,32,226,226,126,124,32,32,126
351 | !byte 124,226,226,226,124,226,226,226,124,226,226,226,124,124,226,226,124,226,226,226,124,226,226,124,226,226,226,124,226,226,226,124,124,226,226,226,124,226,226,126
352 | LScrEnd
353 |
354 | LogoClr
355 | !byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
356 | !byte 0,50,50,50,50,50,50,50,50,50,50,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,50,50,50,50,50,50,50,50,50,50,0
357 | !byte 103,103,103,103,103,103,103,103,103,103,103,0,0,0,0,0,0,0,50,0,0,0,0,0,0,0,0,0,0,103,103,103,103,103,103,103,103,103,103,103
358 | !byte 101,101,101,101,101,101,101,101,101,101,101,0,0,0,0,0,0,0,50,0,0,0,0,0,0,0,0,0,50,101,101,101,101,101,101,101,101,101,101,101
359 | !byte 70,70,70,70,70,70,70,70,70,70,70,70,70,70,70,70,70,70,70,70,70,70,70,70,70,70,70,70,70,70,70,70,70,70,70,70,70,70,70,70
360 | !byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
361 | !byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
362 | !byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
363 | !byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
364 | !byte 70,70,70,70,70,70,70,70,70,70,70,70,0,70,70,70,70,70,70,70,70,70,70,70,70,70,70,70,70,70,70,70,70,70,70,70,70,70,70,70
365 | LClrEnd
366 |
367 |
368 | _CODESTART_
369 | !pseudopc $7000 {
370 | CODESTART:
371 | JMP MainPrg ; Jump to MainPrg
372 |
373 | ; Variables
374 |
375 | TXBYTE !byte $00 ; Byte to be transmitted
376 | RXBYTE !byte $00 ; Last received byte
377 | CMDFlags !byte $00 ; Command flags
378 | ; Bit 7 (N): 1 = Last received byte is CMDON ($ff); 0 = Normal operation
379 | ; Bit 6 (V): 1 = Receive N bytes as parameters and wait for the command to complete; 0 = Normal operation
380 | ; Bits 3-0: Parameter counter for bit-6
381 | TEMPCNT1 !byte $00 ; Temporal counter 1
382 | BYTECNT = $61 ;!word $0000 ; 16-bit block transfer remaining bytes to receive counter
383 | BLOCKPTR !word $0000 ; Memory pointer for the block transfer command
384 |
385 | BORDERCLR !byte $00 ; Current screen border color backup
386 | FLAGS1 !byte $00 ; Status flags
387 | ; Bit 7 (N): 1 = Command mode; 0 = Normal mode
388 | ; Bit 6 (V): 1 = Last byte should be redirected to the voice synth; 0 = Last byte is meant for the terminal
389 | ; Bit 4 : 1 = Split screen enabled
390 | ; Bit 3 : 1 = Cursor blink enabled; 0 = Cursor blink disabled
391 | ; Bit 2 : 1 = Microsint enabled; 0 = Microsint disabled / not found
392 | ; Bit 1 : 1 = Terminal is starting up; 0 = Normal operation
393 | ; Bit 0 : 1 = RUN/STOP pressed, returning to BASIC
394 | ; -----
395 | PRBUFFERCNT !byte $00 ; Print buffer byte counter
396 | PRINDEXOUT !byte $00 ; Index to the print buffer byte to output next
397 | PRINDEXIN !byte $00 ; Index to the first free byte in the print buffer
398 | ; -----
399 | PRBYTE !byte $00 ; |UNUSED| Byte to be printed on screen
400 | PRSPEED !byte $00 ; Text print delay (0:no delay)
401 |
402 | WTOP !byte $00 ; Text window top limit
403 | WBOTTOM !byte $19 ; Text window bottom limit
404 | TIMER1 !byte $00 ; Timer decremented on each interrupt call
405 | CRSRTIMER !byte $00 ; Cursor blink timer, decremented on each interrupt call
406 | CRSRCHAR !byte $00 ; Character currently under the cursor
407 | CRSRCOLOR !byte $00 ; Color of the character under the cursor
408 | TEMPCNT2 !byte $00 ; Temp counter 2
409 | BEEPTIMER !byte $00 ; Timer que decrementa en cada interrupcion
410 | TIMERDIV4 !byte $00 ; Timer que decrementa en cada interrupcion, usado para realizar acciones cada 4 interrupciones
411 | DELAYTIME !byte $00 ; Parametro (tiempos) de las rutinas de temporizacion
412 | SNDSTATUS !byte $00 ; Character beep enable
413 | FLASHSTATUS !byte $00 ; FLASHON control code enable
414 | SPLITRST !byte $00 ; Split screen raster line
415 |
416 | ;///////////////////////////////////////////////////////////////////////////////////
417 | ; ReadByte, receive a byte, store in RXBYTE
418 | ;---------------------------------------------------------------------------------------
419 |
420 | ReadByte
421 | LDA FLAGS1 ; Ignore reception if the terminal is initializing
422 | AND #%00000010
423 | BNE CancelRX
424 | EnRTS
425 | rb1l:
426 | LDA #$1C
427 | STA $FF02
428 | rb1h:
429 | LDA #$00
430 | STA $FF03 ; Wait ~30uS
431 | LDA #%10010000 ; Clear Timer 2 IRQ
432 | STA $FF09
433 |
434 | LDA #%00001011 ; no parity, no echo, no tx irq (rts=0, enable transmision), no rx irq, rx enabled (dtr=0)
435 | STA ACIACOMMAND
436 | LDA #$10
437 | WaitRX1
438 | BIT $FF09
439 | ;AND #$10
440 | BEQ WaitRX1
441 |
442 | DisRTS
443 | LDA #%00000011 ; no parity, no echo, no tx irq (rts=1, disable transmision), no rx irq, rx enabled (dtr=0)
444 | STA ACIACOMMAND
445 | LDA #$EE ;$D2 ; 2 Set Timer A to 2000 ($06EE) microseconds
446 | STA $FF02 ; 4
447 | LDA #$06 ;$01 ; 2
448 | STA $FF03 ; 4
449 | LDA #%10010000 ; 2 Clear Timer 2 IRQ bit
450 | STA $FF09 ; 4
451 | WaitRX2
452 | LDA ACIASTATUS ; Check if a byte has arrived
453 | AND #%00001000
454 | BNE Received ; 3 If the time has elapsed, (85+174 us with no reception), continue on CancelRX
455 | LDA $FF09 ; 4 If 85 microseconds have not yet elapsed on Timer A...
456 | AND #%00010000 ; 2
457 | BEQ WaitRX2 ; 2 Loop back to WaitRX2 to give enough for a byte to arrive
458 | CancelRX
459 | LDA #$00 ; 2 Set RXBYTE to 0
460 | STA RXBYTE ; 4
461 | CLC ; 2 Reset CARRY (no reception)
462 | RTS ; 6 Return
463 | Received
464 | LDA ACIADATA ; 4 Read the received byte
465 | STA RXBYTE ; 4 and store it in RXBYTE
466 | SEC ; 2 Set CARRY (byte received)
467 | RTS ; 6 Return
468 |
469 | ;//////////////////////////////////////////////////////////////////////////////////////////
470 | ; TurboRX, receives a byte stream and plays it as nibbles through the TED volume register
471 | ;------------------------------------------------------------------------------------------
472 |
473 | TurboRX
474 | LDA #%00001011 ; no parity, no echo, no tx irq (rts=0, enable reception), no rx irq, rx enabled (dtr=0)
475 | STA ACIACOMMAND
476 | TurboLoop
477 | LDA #$FB ; Set keyboard latches
478 | STA $FD30
479 | STA $FF08
480 | TXA ; 2
481 | AND #$0F ; 2
482 | TAY
483 | LDA trtable,Y
484 | STA $FF11 ; 4 Write the first sample
485 | STA $FF19 ; 4 <-
486 |
487 | TXA ; 2 Prepare second sample
488 | ROR ; 2
489 | ROR ; 2
490 | ROR ; 2
491 | ROR ; 2
492 | AND #$0F ; 2
493 | ;TAX ; 2 <-18 cycles until here
494 | TRXWait1
495 | ; Wait 86 - 16 - 18 cycles for 11520Khz
496 | ; Wait 130 - 16 - 18 cycles for 7680KHz
497 | LDY #$41
498 | - DEY ; 2
499 | BNE -
500 |
501 | TAY
502 |
503 | LDA trtable,Y
504 | STA $FF11 ; 4 Write second sample
505 | STA $FF19 ; 4
506 | TRXWait2
507 | -
508 | LDA ACIASTATUS ; 4 Wait for a character
509 | AND #%00001000 ; 2
510 | BEQ - ; 3
511 | LDA ACIADATA ; 4 .A = Received character
512 | TAX ; 2
513 | BEQ TurboExit
514 |
515 | LDA $FF08 ; 4 Key press?
516 | CMP #$FF
517 | BEQ TurboLoop ; 3
518 | LDA #$FF ; Yes, send $FF
519 | STA ACIADATA
520 | JMP TurboLoop ; 3
521 |
522 | TurboExit
523 | LDA #%00000011 ; no parity, no echo, no tx irq (rts=1, reception disabled), no rx irq, rx enabled (dtr=0)
524 | _acomm4
525 | STA ACIACOMMAND
526 | RTS
527 | ; 4-bit sample to 13 TED amplitudes
528 | trtable:
529 | !byte $90,$91,$92,$93,$94,$95,$96,$97,$98,$B5,$B5,$B6,$B7,$B7,$B8,$B8
530 |
531 |
532 | ;///////////////////////////////////////////////////////////////////////////////////
533 | ; Programa principal
534 | ;///////////////////////////////////////////////////////////////////////////////////
535 |
536 | MainPrg
537 | JSR InitPalette
538 | JSR $D88B ; Clear Screen (Makes sure the Screen link table is valid from here on)
539 | SEI ; Disable interrupts
540 |
541 | LDA #$00 ; Black screen and border
542 | STA $FF15
543 | STA $FF19
544 | STA $0540 ; Repeat Space, INS/DEL and cursor keys only
545 |
546 | LDA #%00000010 ; no parity, no echo, no tx irq (rts=1), no rx irq, rx disabled (dtr=1)
547 | STA ACIACOMMAND
548 | LDA #%00011111 ; 1 stop bit, 8 data bits, baud rate generator, 19200 bps
549 | ; LDA #%00011000 ; 1 stop bit, 8 data bits, baud rate generator, 1200 bps
550 | STA ACIACONTROL
551 | LDA #$00 ; Inicializa el buffer de impresion
552 | STA PRINDEXOUT
553 | STA PRINDEXIN
554 | STA PRBUFFERCNT
555 | LDA #%00001010 ; Terminal is initializing
556 | STA FLAGS1
557 | LDA #32 ; Sets a space as initial character under the cursor
558 | STA CRSRCHAR
559 | LDA #4 ; Init TIMERDIV4
560 | STA TIMERDIV4
561 | LDA #0 ; Reset beep counters
562 | STA TEMPCNT1
563 | STA TEMPCNT2
564 |
565 | ResetFkeys
566 | LDX #$07
567 | - LDA FTable,X
568 | STA $0567,X
569 | LDA #$01
570 | STA $055F,X
571 | DEX
572 | BPL -
573 |
574 | ConfigTED
575 | LDA #%00000000 ; Volume = 0 (min), disable channels 1 & 2 and reset the oscilators
576 | STA $FF11
577 | LDA #$03
578 | STA $FF10 ; Voice 2 freq
579 | LDA #$9a
580 | STA $FF0F
581 | LDA #$10 ; Enable TED screen
582 | ORA $FF06
583 | STA $FF06
584 | ; LDA #%11111110 ; Clear most significant bit in TED's raster register
585 | ; AND $FF0A
586 | ; STA $FF0A
587 | LDA #204 ; Set the raster line number where interrupt should occur
588 | STA $FF0B
589 | LDA #Irq
592 | STA $0315
593 | LDA #%10100010 ; Enable raster interrupt signals from TED, and clear MSB in TED's raster register
594 | STA $FF0A
595 |
596 | ; Set STREND variable (needed by the PAINT ROM routine)
597 | LDA #$00
598 | STA $31
599 | LDA #$40
600 | STA $32
601 |
602 | CLI
603 | LDX #Version
606 | ;STA AddTLoop + 2
607 | JSR AddText ; y la agrega al buffer de impresion
608 | LDA #1 ; Velocidad: 1 caracter por cuadro
609 | STA PRSPEED
610 | STA TIMER1
611 | ;JSR StopCRSR
612 | JSR PrintBuffer ; Procesa el buffer de impresion
613 | ;JSR StartCRSR
614 |
615 | LDA #100 ; Espera 2 segundos
616 | STA PRSPEED
617 | STA TIMER1
618 | LDA #0 ; Inicializa el temporizador del cursor para que empiece encendido
619 | STA CRSRTIMER
620 | Wait1 JSR BlinkCRSR ; Procesa el parpadeo del cursor
621 | LDA TIMER1
622 | BNE Wait1
623 |
624 | LDA #$00 ; A partir de ahora imprime sin retardo
625 | STA PRSPEED
626 | STA TIMER1
627 |
628 | LDX #Msg06
631 | ;STA AddTLoop + 2
632 | JSR AddText ; and it's added to the print buffer
633 | JSR PrintBuffer ; Process the print buffer
634 |
635 | LDA #0 ; Inicializa el temporizador del cursor para que empiece encendido
636 | STA CRSRTIMER
637 | LDA FLAGS1 ; Se termino de inicializar la terminal
638 | AND #%11111101
639 | STA FLAGS1
640 | PrintRX
641 | LDA PRBUFFERCNT ; Si no hay elementos en el buffer para imprimir, sigue en Blink
642 | BEQ Blink
643 | LDA TIMER1 ; Si no es momento de imprimir (TIMER1<>0), sigue en Blink
644 | BNE Blink
645 | ;JSR StopCRSR
646 | JSR PrintBuffer ; Procesa el buffer de impresion
647 | ;JSR StartCRSR
648 | Blink
649 | LDA #%00000001 ; Verifica si hay que volver al BASIC
650 | AND FLAGS1
651 | BEQ +
652 | JMP ExitPrg ; si es asi, sigue en ExitPrg para salir del programa
653 | + JSR BlinkCRSR ; sino, procesa el parpadeo del cursor
654 | JMP PrintRX ; y vuelve a PrintRX
655 |
656 | ;///////////////////////////////////////////////////////////////////////////////////
657 | ; Blink the cursor
658 | ;///////////////////////////////////////////////////////////////////////////////////
659 |
660 | BlinkCRSR
661 | LDA FLAGS1
662 | AND #%00001000
663 | BEQ BlinkEnd
664 | LDA CRSRTIMER ; Continue to BlinkEnd if this is not the time to reverse the cursor (CRSRTIMER<>0)
665 | BNE BlinkEnd
666 | LDA #30 ; Reset CRSRTIMER
667 | STA CRSRTIMER
668 | LDX CRSRCOLOR
669 | LDY CURRCOLUMN
670 | LDA #%10000000 ; reverse the character under the cursor
671 | EOR (CURRLINEPTR), Y
672 | STA (CURRLINEPTR), Y
673 | BPL +
674 | LDX $053B
675 | + TXA
676 | STA ($EA),Y
677 | BlinkEnd
678 | RTS
679 |
680 | ;///////////////////////////////////////////////////////////////////////////////////
681 | ; Disables the cursor, restores the character under it
682 | ;///////////////////////////////////////////////////////////////////////////////////
683 |
684 | StopCRSR
685 | LDY CURRCOLUMN
686 | LDA CRSRCHAR
687 | STA (CURRLINEPTR), Y
688 | LDA CRSRCOLOR
689 | STA ($EA),Y
690 | RTS
691 |
692 | ;///////////////////////////////////////////////////////////////////////////////////
693 | ; Enable the cursor, saves the character under it
694 | ;///////////////////////////////////////////////////////////////////////////////////
695 |
696 | StartCRSR
697 | LDY CURRCOLUMN
698 | LDA (CURRLINEPTR), Y
699 | STA CRSRCHAR
700 | LDA ($EA),Y
701 | STA CRSRCOLOR
702 | LDA #0 ; Inicializa el temporizador del cursor para que empiece encendido
703 | STA CRSRTIMER
704 | RTS
705 |
706 | ;///////////////////////////////////////////////////////////////////////////////////
707 | ; Print the entire buffer
708 | ;///////////////////////////////////////////////////////////////////////////////////
709 |
710 | PrintBuffer
711 | JSR StopCRSR
712 | .pb0
713 | LDA PRBUFFERCNT ; If the buffer is empty, continues on PrintEnd
714 | BEQ PrintEnd
715 | ;BNE +
716 | ;LDA #$01
717 | ;STA TIMER1
718 | - ;LDA TIMER1 ; If it's not the time to print (TIMER1<>0), waits
719 | ;BNE -
720 | ;JSR NoChar ; Mutes the print beep
721 | ;BNE PrintEnd
722 | + LDA TIMER1 ; If its not the time to print (TIMER1<>0), returns to .pb0
723 | BNE .pb0
724 | LDX PRINDEXOUT
725 | ;LDA #%11000000 ; Checks the flags states
726 | BIT FLAGS1
727 | BMI .pb2 ; Command mode? -> Parse comnands
728 | BVS .pb4 ; Voice mode, continue on .PB4
729 | LDA PrBuffer, X
730 | CMP #$FF ; Check for commands
731 | BEQ .pb1
732 |
733 | CMP #$FE ; Check for command mode exit <- Captures extraneous $FE characters
734 | BEQ .pb2
735 |
736 | JSR CharOut ;CHROUT replacement routine (Codebase)
737 | LDA SNDSTATUS
738 | BNE ++
739 | JSR Beep ; Print beep
740 | ++ INC PRINDEXOUT
741 | DEC PRBUFFERCNT
742 | LDA PRSPEED ; Renew TIMER1 with PRSPEED
743 | STA TIMER1
744 | JMP .pb0 ; Return to .pb0 to process the rest of the buffer
745 | PrintEnd
746 | ; LDA TEMPCNT2
747 | ;- CMP TEMPCNT2
748 | ; BEQ -
749 | ; JSR NoChar
750 | JMP StartCRSR
751 | ; RTS
752 | ; // Enter command mode
753 | .pb1
754 | INC PRINDEXOUT
755 | DEC PRBUFFERCNT ; Skip the $FF character
756 | LDA FLAGS1
757 | ORA #%10000000 ; Enters command mode
758 | STA FLAGS1
759 | BNE .pb0
760 | ; Parse commands
761 | .pb2
762 | JSR NoChar ; Mutes the print beep
763 | INC PRINDEXOUT
764 | DEC PRBUFFERCNT ; Update pointers
765 | LDA PrBuffer,X
766 | BPL + ; Invalid command (bit7=0)
767 | CMP #MAXCMD+1
768 | BCC ++ ; Is it less than or equal to the highest implemented command ($B6)?
769 | + LDA #$8F ; Invalid command, replace with unimplemented command ($8F)
770 | ++ AND #%01111111 ; -128
771 | ASL
772 | TAY
773 | LDA CmdTable+1,Y
774 | STA .pb3+2
775 | LDA CmdTable,Y ; Point the JSR to the command address (self-modifying)
776 | STA .pb3+1
777 | .pb3
778 | JSR CmdFE ; Command call<<<<
779 | LDA #$00
780 | STA CMDFlags ; Command completed, reset CMDFlags
781 | JMP .pb0 ; Return to .pb0 to process the rest of the buffer
782 |
783 | .pb4 ; Insert byte into the voice buffer
784 | JSR NoChar ; Mute the print beep
785 | LDA PrBuffer,X
786 | CMP #$FF ; Check for commands
787 | BEQ .pb1
788 | INC PRINDEXOUT
789 | DEC PRBUFFERCNT
790 | JMP .pb0
791 |
792 | ;///////////////////////////////////////////////////////////////////////////////////
793 | ; CHROUT replacement, equivalent to the Kernal routine but no quote mode, 40
794 | ; logical columns and text window support
795 | ; Petscii -> Screen code by Mace (from Codebase64)
796 | ;///////////////////////////////////////////////////////////////////////////////////
797 | CharOut:
798 | CMP #$20 ; if A<32 then...
799 | BCC ddCtrl ; Control characters->
800 |
801 | CMP #$60 ; if A<96 then...
802 | BCC dd1
803 |
804 | CMP #$80 ; if A<128 then...
805 | BCC dd2
806 |
807 | CMP #$a0 ; if A<160 then...
808 | BCC ddCtrl ; Control characters->
809 |
810 | CMP #$c0 ; if A<192 then...
811 | BCC dd4
812 |
813 | CMP #$ff ; if A<255 then...
814 | BCC ddRev
815 |
816 | LDA #$7e ; A=255, then A=126
817 | BNE ddEnd
818 |
819 | dd2 AND #$5f ; if A=96..127 then strip bits 5 and 7
820 | BNE ddEnd
821 |
822 | dd4 EOR #$c0 ; if A=160..191 then flip bits 6 and 7
823 | BNE ddEnd
824 |
825 | dd1 AND #$3f ; if A=32..95 then strip bits 6 and 7
826 | BPL ddEnd ; <- you could also do .byte $0c here
827 |
828 | ddRev
829 | EOR #$80 ; flip bit 7 (reverse on when off and vice versa)
830 | ddEnd
831 | LDX $C7
832 | BEQ +
833 | ORA #$80 ; Inverse video
834 |
835 | + LDY CURRCOLUMN
836 | LDX CURRLINE
837 | STA (CURRLINEPTR),Y ; Write character to screen
838 | JSR $E008 ; Update Attributes
839 | INY
840 | CPY #40 ; Reached right border?
841 | BNE cu1 ; No, go update screen pointers
842 | LDY #00 ; Wrap to column 0
843 | INX
844 | CPX WBOTTOM ; Pass bottom window border?
845 | BCC cu1 ; No, go update screen pointers
846 | DEX
847 | TXA
848 | PHA
849 | TYA
850 | PHA
851 | JSR $DA89 ; Scroll text window
852 | PLA
853 | TAY
854 | PLA
855 | TAX
856 |
857 | cu1 STY CURRCOLUMN
858 | STX CURRLINE
859 | JSR $D8AA ; Set start of line (.X = line)
860 | ;JSR $EA24 ; Synchronize color RAM pointer
861 | ce0 RTS
862 | ddCtrl ;Control chars
863 | CMP #$13 ; Check for HOME
864 | BNE + ; No, next
865 | LDX WTOP
866 | LDY #$00
867 | BEQ cu1
868 | + CMP #$93 ; Check for CLEAR
869 | BNE + ; No, next
870 | LDX WBOTTOM
871 | - DEX
872 | JSR $DAF7 ; Clear Line
873 | CPX WTOP
874 | BNE -
875 | LDX WTOP
876 | LDY #$00
877 | BEQ cu1
878 | + CMP #$91 ; Check for Cursor UP
879 | BNE + ; No, next
880 | LDX CURRLINE
881 | CPX WTOP ; Cursor at the top of the text window?
882 | BEQ ce0 ; Yes, do nothing
883 | DEX
884 | BPL cu1+2
885 | + CMP #$11 ; Check for Cursor DOWN
886 | BNE + ; No, next
887 | LDX CURRLINE
888 | INX
889 | CPX WBOTTOM ; Cursor beyond the bottom of the text window?
890 | BNE cu1+2 ; No, update pointers
891 | DEX
892 | TXA
893 | PHA
894 | JSR $DA89 ; Yes, scroll text window
895 | PLA
896 | TAX
897 | BNE cu1+2
898 | + CMP #$9D ; Check for Cursor LEFT
899 | BNE ++ ; No, next
900 | LDX CURRLINE
901 | LDY CURRCOLUMN
902 | DEY
903 | BPL cu1 ; Cursor still on same row -> update pointers
904 | CPX WTOP
905 | BEQ + ; Cursor is already at the text window's HOME
906 | DEX
907 | LDY #38 ; < 39-1, to be incremented to the correct value further ahead
908 | + INY ; 38 to 39 if going up a row, 255 to 0 if already at HOME
909 | BPL cu1 ; update pointers
910 | ++ CMP #$1D ; Check for Cursor RIGHT
911 | BNE + ; No, next
912 | LDX CURRLINE
913 | LDY CURRCOLUMN
914 | INY
915 | CPY #40 ; Beyond column 40?
916 | BNE cu1 ; No, update pointers
917 | LDY #$00
918 | INX
919 | CPX WBOTTOM ; Do we need to scroll?
920 | BNE cu1 ; No, update pointers
921 | TXA
922 | PHA
923 | TYA
924 | PHA
925 | JSR $DA89 ; Yes, scroll
926 | PLA
927 | TAY
928 | PLA
929 | TAX
930 | DEX
931 | JMP cu1
932 | + CMP #$0D ; Check for RETURN
933 | BEQ +
934 | CMP #$8D ; Check for SHIFT-RETURN
935 | BNE ++
936 | + LDX CURRLINE
937 | LDY #0
938 | STY $C7
939 | INX
940 | CPX WBOTTOM ; Beyond the text window's bottom?
941 | BEQ +
942 | JMP cu1 ; No, move cursor
943 | + DEX
944 | TXA
945 | PHA
946 | TYA
947 | PHA
948 | JSR $DA89 ; Yes, scroll
949 | PLA
950 | TAY
951 | PLA
952 | TAX
953 | + JMP cu1
954 | ++ CMP #$14 ; Check for DELETE
955 | BNE ++ ; No, next
956 | LDX CURRLINE
957 | LDY CURRCOLUMN
958 | BEQ + ; If already on column 0, branch
959 | DEY
960 | STY CURRCOLUMN
961 | - INY
962 | LDA (CURRLINEPTR),Y
963 | DEY
964 | STA (CURRLINEPTR),Y
965 | INY
966 | LDA ($EA),Y
967 | DEY
968 | STA ($EA),Y
969 | INY
970 | CPY #39
971 | BNE -
972 | LDA #$20 ; Space
973 | STA (CURRLINEPTR),Y
974 | LDA $053B
975 | STA ($EA),Y
976 | - JMP cu1+2
977 | + CPX WTOP
978 | ; BNE + ; At HOME?
979 | BEQ + ; Yes, do nothing <<<<<<<<<<<<<<<<<<<<<
980 | ;RTS ; Yes, do nothing
981 | ;+
982 | LDY #39
983 | STY CURRCOLUMN
984 | DEX
985 | STX CURRLINE
986 | JSR $D8AA ; Update pointers
987 | LDA #$20 ; Space
988 | STA (CURRLINEPTR),Y
989 | LDA $053B
990 | STA ($EA),Y
991 | + RTS
992 | ++ CMP #$82 ; Check for FLASH ON
993 | BNE++
994 | LDA FLASHSTATUS
995 | BEQ + ; if disabled do nothing
996 | RTS
997 | + LDA #$80
998 | STA $53C
999 | RTS
1000 | ++ CMP #$84 ; Check for FLASH OFF
1001 | BNE +
1002 | LDA #$00
1003 | STA $53C
1004 | RTS
1005 | + CMP #$94 ; Check for INSERT
1006 | BNE ++ ; No, siguiente
1007 | LDY #39
1008 | LDA (CURRLINEPTR),Y
1009 | CMP #$20 ; Space in the row's last column?
1010 | BEQ +
1011 | - RTS ; No, do nothing
1012 | + CPY CURRCOLUMN ; Cursor at the last column?
1013 | BEQ - ; Yes, do nothing
1014 | - DEY
1015 | LDA (CURRLINEPTR),Y
1016 | INY
1017 | STA (CURRLINEPTR),Y
1018 | DEY
1019 | LDA ($EA),Y
1020 | INY
1021 | STA ($EA),Y
1022 | DEY
1023 | CPY CURRCOLUMN
1024 | BNE -
1025 | LDA #$20
1026 | STA (CURRLINEPTR),Y
1027 | LDA $053B
1028 | STA ($EA),Y
1029 | RTS
1030 | ++ CMP #$12 ; Check for RVSON
1031 | BNE + ; No, next
1032 | LDA #$01
1033 | STA $C7 ; Reverse ON
1034 | RTS
1035 | + CMP #$92 ; Check for RVSOFF
1036 | BNE + ; No, next
1037 | LDA #$00
1038 | STA $C7 ; Reverse OFF
1039 | RTS
1040 | + CMP #$08 ; Check disable CBM+SHIFT
1041 | BNE + ; No, next
1042 | LDA #$80
1043 | STA $0547
1044 | RTS
1045 | + CMP #$09 ; Check enable CBM+SHIFT
1046 | BNE + ; No, next
1047 | LDA #$00
1048 | STA $0547
1049 | RTS
1050 | + CMP #$0E ; Check switch to Uppercase/Lowercase
1051 | BNE +
1052 | LDA $FF13
1053 | ORA #$04
1054 | BNE ++
1055 | + CMP #$8E ; Check switch to Uppercase/Graphics
1056 | BNE +
1057 | LDA $FF13
1058 | AND #%11111011
1059 | ++ STA $FF13
1060 | RTS
1061 | + CMP #$07 ; Check for BELL
1062 | BNE +
1063 | LDA #BEEPTIME
1064 | STA BEEPTIMER
1065 | LDA $FF11
1066 | ORA #%00110100
1067 | STA $FF11
1068 | RTS
1069 | + JMP $DCE6 ; Check colors (Kernal)
1070 |
1071 | ;///////////////////////////////////////////////////////////////////////////////////
1072 | ; Print beep
1073 | ;///////////////////////////////////////////////////////////////////////////////////
1074 | Beep
1075 | LDA BEEPTIMER
1076 | BNE +
1077 | LDA #BEEPTIME
1078 | STA BEEPTIMER ; Reset beep timer
1079 | + LDA #$01 ; if TEMPCNT1 is odd jump to DoBeep2
1080 | AND TEMPCNT1
1081 | BNE +
1082 | LDA #$1A ; Freq channel 1 = ~470 Hz
1083 | BNE ++
1084 | + LDA #$45 ; Freq channel 1 = ~590 Hz
1085 | ++ STA $FF0E
1086 | LDA $FF12
1087 | AND #$FC
1088 | ORA #$03
1089 | STA $FF12
1090 | LDA #%00010010 ; Volume = 2 (Low), enable channels 1 & 2 in tone mode
1091 | ORA $FF11
1092 | STA $FF11
1093 |
1094 | INC TEMPCNT1
1095 | RTS ;JMP EndBeep
1096 |
1097 | NoChar
1098 | LDA #%00010000 ; Volume = 0
1099 | STA $FF11
1100 | RTS
1101 |
1102 | ;///////////////////////////////////////////////////////////////////////////////////
1103 | ; Insert a string into the print buffer
1104 | ;///////////////////////////////////////////////////////////////////////////////////
1105 |
1106 | AddText
1107 | STX AddTLoop + 1
1108 | STY AddTLoop + 2
1109 |
1110 | LDX #$00
1111 | AddTLoop
1112 | LDA PrBuffer, X
1113 | BNE +
1114 | RTS ; Exit if character is 0
1115 | +
1116 | ; SEI
1117 | JSR AddToPrBuffer ; Insert character into the print buffer
1118 | ; CLI
1119 | INX
1120 | JMP AddTLoop ; loop
1121 |
1122 | ;///////////////////////////////////////////////////////////////////////////////////
1123 | ; Get a character from the print buffer
1124 | ;///////////////////////////////////////////////////////////////////////////////////
1125 | GetFromPrBuffer
1126 | LDA PRBUFFERCNT
1127 | BEQ GetFromPrBuffer ; Wait for a character in the print buffer
1128 | LDX PRINDEXOUT
1129 | INC PRINDEXOUT
1130 | DEC PRBUFFERCNT ; Update pointers
1131 | LDA PrBuffer,X ; Get character
1132 | RTS
1133 |
1134 | ;///////////////////////////////////////////////////////////////////////////////////
1135 | ; Insert the character in .A, to the print buffer
1136 | ;///////////////////////////////////////////////////////////////////////////////////
1137 |
1138 | AddToPrBuffer
1139 | PHA
1140 | LDY PRINDEXIN ; Loads .Y with PRINDEXIN
1141 | - LDA PRBUFFERCNT ; If PRBUFFERCNT=255 (buffer full) waits until a space is open
1142 | EOR #$FF
1143 | BEQ -
1144 | ;SEI ;Disable IRQs
1145 | PLA
1146 | STA PrBuffer, Y
1147 | INC PRINDEXIN ; Increment PRINDEXIN
1148 | INC PRBUFFERCNT ; and PRBUFFERCNT
1149 | ;CLI ; Enable IRQs
1150 | RTS
1151 |
1152 | ;///////////////////////////////////////////////////////////////////////////////////
1153 | ; Wait until the print buffer is empty
1154 | ;///////////////////////////////////////////////////////////////////////////////////
1155 |
1156 | WaitPrint
1157 | LDA PRBUFFERCNT ; Wait for PRBUFFERCNT == 0
1158 | BNE WaitPrint
1159 | RTS
1160 |
1161 | ;///////////////////////////////////////////////////////////////////////////////////
1162 | ; Return to BASIC
1163 | ;///////////////////////////////////////////////////////////////////////////////////
1164 |
1165 | ExitPrg
1166 | SEI ; Disable IRQ
1167 | JSR b3cancel2 ; Cancel split screen
1168 | JSR _txtmode ; Switch to text mode
1169 | LDA #24
1170 | STA $07E5
1171 | LDA #$0F ; Volume = 15 (max), disable channels 1 & 2
1172 | STA $FF11
1173 | ; LDA #32 ; Imprime un espacio
1174 | ; JSR CHROUT
1175 | LDA #ExitMsg
1177 | JSR STROUT ;PrintTxt
1178 | LDA #%00000010 ; no parity, no echo, no tx irq (rts=1), no rx irq, rx disabled (dtr=1)
1179 | STA ACIACOMMAND
1180 | LDA #$0E ; Restore default IRQ vector
1181 | STA $0314
1182 | LDA #$CE
1183 | STA $0315
1184 | LDA #161 ; Set the raster line number where interrupt should occur
1185 | STA $FF0B
1186 | LDA #%10100010 ; Enable raster interrupt signals from TED, and clear MSB in TED's raster register
1187 | STA $FF0A
1188 | LDA #0 ; Flush keyboard buffer
1189 | STA $EF
1190 | CLI ; Enable IRQ
1191 | JMP $867E ; Returns to BASIC
1192 |
1193 | ;///////////////////////////////////////////////////////////////////////////////////
1194 | ; Interrupt routine
1195 | ;///////////////////////////////////////////////////////////////////////////////////
1196 |
1197 | Irq
1198 | PHA ; store register A in stack
1199 | TXA
1200 | PHA ; store register X in stack
1201 | TYA
1202 | PHA ; store register Y in stack
1203 |
1204 |
1205 | ChkTimer1
1206 | LDA TIMER1 ; Decrement TIMER1 if !=0
1207 | BEQ ChkTimer2
1208 | DEC TIMER1
1209 | ChkTimer2
1210 | LDA CRSRTIMER ; Decrement CRSRTIMER if != 0
1211 | BEQ +
1212 | DEC CRSRTIMER
1213 | +
1214 |
1215 | ChkBuffer
1216 | LDA PRBUFFERCNT
1217 | BNE ReadBytes
1218 |
1219 | ;///////////////////////////////////////////////////////////////////////////////////
1220 | ; Generate the screen printing beep
1221 |
1222 | DoBeep
1223 | LDA BEEPTIMER ; Decrement BEEPTIMER if != 0
1224 | BEQ ReadBytes
1225 | DEC BEEPTIMER
1226 | BNE ReadBytes
1227 |
1228 | NoBeep
1229 | LDA #%00010000 ; Volume = 8 (max), enable channels 1 & 2 in tone mode and restart the oscilators
1230 | STA $FF11
1231 | EndBeep
1232 |
1233 | ;///////////////////////////////////////////////////////////////////////////////////
1234 | ; Read up to 3 bytes from the RS232 port
1235 |
1236 | ReadBytes
1237 | LDA #%10100000 ; Disable raster interrupt signals from TED, and clear MSB in TED's raster register
1238 | STA $FF0A
1239 |
1240 | LDA FLAGS1
1241 | AND #%00010000 ; Is screen split enabled?
1242 | BEQ+
1243 | LDA SPLITRST
1244 | STA $FF0B
1245 | LDA #IrqB3
1248 | STA $0315
1249 | LDA VMODE
1250 | ORA $FF07
1251 | STA $FF07
1252 | LDA #$18 ; Attributes at $1800
1253 | STA $FF14
1254 | LDA $FF12
1255 | AND #$FB ; Bitmap in RAM
1256 | STA $FF12 ; Bitmap at $2000
1257 | LDA UPBGC
1258 | STA $FF15 ; Upper background color
1259 | LDA #$3B ; Bitmap mode
1260 | BNE ++
1261 |
1262 | + LDA #$10 ; Enable TED screen
1263 | ORA $FF06
1264 | ++ STA $FF06
1265 |
1266 | LDX #$03 ; Read up to 3 bytes from RS232
1267 | ReadBLoop
1268 | LDA PRBUFFERCNT ; if PRBUFFERCNT=255 (buffer full) continue to ReadBEnd
1269 | EOR #$FF
1270 | BEQ ReadBEnd
1271 |
1272 | LDA #%00001111 ; Z = 0 if there's no parameters left to receive
1273 | BIT CMDFlags ; Check command flags
1274 | BVC + ; If we're not waiting for parameters, receive character
1275 | BEQ ReadBEnd ; If we were waiting for parameters but all were received, do not receive more characters
1276 | ; until the command is completed
1277 | + JSR ReadByte ; Receive a character from RS232
1278 | BCC ++ ;ReadBEnd ; If none is received, continue on Speak
1279 | LDA RXBYTE ; Get the received character
1280 | JSR AddToPrBuffer ; Insert it into the print buffer
1281 |
1282 | ;LDA #%00001111 ; Z = 0 if there's no parameters left to receive
1283 | BIT CMDFlags ; Check command flags
1284 | BMI .cmdchk ; If the last character was CMDON, check which command was received
1285 | BVS + ; Branch if we're waiting for parameters
1286 | LDA RXBYTE ; Not waiting for command or parameters
1287 | BPL ++ ; If bit 7 is not set, it isn't a command
1288 | BIT FLAGS1 ; If bit 7 is set, check that we are in command mode
1289 | BMI .cmdchk ; Yes, it is a command
1290 | EOR #$FF ; Check if the received character is CMDON
1291 | BEQ .cmdon ;BNE ++
1292 | CMP #$01 ; Check if the character is an extraneous CMDOFF
1293 | BNE ++
1294 | LDA #$00 ; Last received characters is an extraneous CMDOFF
1295 | BEQ +++
1296 | .cmdon
1297 | LDA #%10000000 ; Last received character is CMDON
1298 | +++ STA CMDFlags ; Set CMDFlags
1299 | BNE ++
1300 | + DEC CMDFlags ; A parameter character was received, decrement counter
1301 |
1302 | -
1303 | ++ DEX ; Decrementa X
1304 | BNE ReadBLoop ; if != 0, return to ReadBLoop
1305 | BEQ ReadBEnd ; Continue on Speak
1306 |
1307 | .cmdchk ; Check the received command and set CMDFlags accordingly
1308 | LDA RXBYTE ; Get the received character
1309 | BPL + ; Invalid command (bit 7 unset)
1310 | CMP #MAXCMD+1
1311 | BCC ++ ; Is it less than or equal to the highest implemented command ($B6)?
1312 | + LDA #$8F ; Invalid command, replace with unimplemented command ($8F)
1313 | ++ AND #%01111111 ; -128
1314 | TAY
1315 | LDA CmdParTable,Y ; Parameter count
1316 | AND #%00001111 ; Clear unwanted bits
1317 | ORA #%01000000 ; Enable parameter wait
1318 | STA CMDFlags ; Set CMDFlags
1319 | BNE - ; Continue the loop
1320 |
1321 |
1322 | ; JSR ReadByte ; Lee un byte desde el RS232
1323 | ; BCC ReadBEnd ; Si no se recibio nada, sigue en ReadBEnd
1324 | ; LDA RXBYTE ; Lee el byte recibido
1325 | ; JSR AddToPrBuffer ; Agrega el byte al buffer de impresion
1326 | ; ; JMP ReadBNext ; sigue en ReadBNext
1327 | ; ReadBNext
1328 | ; DEX ; Decrementa X
1329 | ; BNE ReadBLoop ; Si no llego a 0, vuelve a ReadBLoop
1330 | ReadBEnd
1331 |
1332 | ChkKey
1333 | JSR GETIN ; Read from the keyboard buffer
1334 | BEQ ExitIrq ; No key? Continue to ExitIrq
1335 | STA TXBYTE ; Copy the character into TXBYTE
1336 | CMP #$03 ;JSR STOP ; Check the STOP key
1337 | BNE +
1338 | LDA #%00000001 ; If STOP is pressed, set the flago to return to BASIC
1339 | ORA FLAGS1
1340 | STA FLAGS1
1341 | LDA #0 ; Reset the STREY flag
1342 | STA $91
1343 | JMP ExitIrq ; and continue to ExitIrq
1344 | + ;LDA TXBYTE ; Check for SHIFT + RETURN
1345 | CMP #$8D
1346 | BNE +
1347 | LDA #$0A ; convert it to LF
1348 | BNE ++
1349 | + CMP #$A7 ; CBM+M
1350 | BNE +
1351 | LDA #$FF
1352 | EOR SNDSTATUS
1353 | STA SNDSTATUS
1354 | JMP ExitIrq
1355 | + CMP #$88 ; F7?
1356 | BNE +
1357 | LDX $0543 ; Shift keys flag
1358 | CPX #$02 ; C= pressed?
1359 | BNE ++
1360 | ;Test terminal not in command mode
1361 | BIT CMDFlags
1362 | BVS ExitIrq
1363 | LDA #>SETUP ; Modify Stack
1364 | PHA
1365 | LDA #IrqB3
1403 | ; STA $0315
1404 | ; LDA VMODE
1405 | ; ORA $FF07
1406 | ; STA $FF07
1407 | ; LDA $FF12
1408 | ; AND #$FB ; Bitmap in RAM
1409 | ; STA $FF12 ; Bitmap at $2000
1410 | ; LDA #$3B ; Bitmap mode
1411 | ; BNE ++
1412 |
1413 | ; + LDA #$10 ; Habilita el TED (activa la pantalla)
1414 | ; ORA $FF06
1415 | ; ++ STA $FF06
1416 |
1417 | LDA $FB
1418 | PHA
1419 | LDA #$00
1420 | STA $FB
1421 | PHP
1422 | CLI
1423 | JSR $DB11 ; Scan keyboard
1424 | PLP
1425 | PLA
1426 | STA $FB
1427 |
1428 |
1429 | PLA
1430 | TAY ; restore register Y from stack
1431 | PLA
1432 | TAX ; restore register X from stack
1433 | PLA ; restore register A from stack
1434 | ;JMP $CE0E ; Jump into KERNAL's standard interrupt service routine to handle keyboard scan, cursor display etc.
1435 | JMP $FCBE
1436 |
1437 | ;///////////////////////////////
1438 | ; Init color codes palette
1439 | ;///////////////////////////////
1440 |
1441 | InitPalette:
1442 | LDX #$0F
1443 | - LDA Palette,X
1444 | STA $0113,X
1445 | DEX
1446 | BPL -
1447 | RTS
1448 |
1449 | ;///////////////////////////////////////////////////////////////////////////////////
1450 | ; SETUP SCREEN
1451 | ;///////////////////////////////////////////////////////////////////////////////////
1452 |
1453 | SETUP:
1454 | +DisROMs
1455 | JSR _SETUP
1456 | +EnROMs
1457 | JMP ExitIrq
1458 |
1459 | ;///////////////////////////////////////////////////////////////////////////////////
1460 | ; COMMANDS
1461 | ;///////////////////////////////////////////////////////////////////////////////////
1462 |
1463 | ;///////////////////////////////////////////////////////////////////////////////////
1464 | ; 128: Set the transfer memory pointer, requires 2 parameter
1465 | ; bytes: destination address (low, high)
1466 |
1467 | Cmd80
1468 | JSR GetFromPrBuffer ; Reads a byte from the print buffer
1469 | STA BLOCKPTR ; and store it in BLOCKPTR
1470 | JSR GetFromPrBuffer ; Reads a byte from the print buffer
1471 | STA BLOCKPTR + 1 ; and store it in BLOCKPTR + 1
1472 | RTS
1473 |
1474 | ;///////////////////////////////////////////////////////////////////////////////////
1475 | ; 129: Select a preset address for memory transfer,
1476 | ; requires 1 parameter byte: Destiny address preset
1477 |
1478 | Cmd81
1479 | LDY #$00
1480 | JSR GetFromPrBuffer ; Reads a byte from the print buffer
1481 | ;EOR #$00
1482 | BEQ Addr00 ; If $00 go to Addr00
1483 | CMP #$10
1484 | BEQ Addr10 ; If $10 go to Addr10
1485 | CMP #$20
1486 | BEQ Addr20 ; If $20 go to Addr20
1487 | INY ; Otherwise set BLOCKPTR to $1001 (BASIC text area)
1488 | LDA #$10
1489 | - STY BLOCKPTR
1490 | STA BLOCKPTR + 1
1491 | RTS
1492 | Addr00
1493 | ; Point BLOCKPTR to $0C00 (3072)
1494 | LDA #$0C
1495 | BNE -
1496 | Addr10
1497 | ; Point BLOCKPTR to $2000 (8192)
1498 | LDA #$20
1499 | BNE -
1500 | Addr20
1501 | ; Point BLOCKPTR to $0800 (2048)
1502 | LDA #$08
1503 | BNE -
1504 |
1505 | ;///////////////////////////////////////////////////////////////////////////////////
1506 | ; 130: Transfers a byte block to memory, requires 2 parameter bytes
1507 | ; Byte count (low, high)
1508 |
1509 | Cmd82
1510 | JSR NoChar ; Mute beep
1511 | JSR GetFromPrBuffer ; Reads a byte from the print buffer
1512 | TAY
1513 | JSR GetFromPrBuffer ; Reads a byte from the print buffer
1514 | TAX
1515 |
1516 | ; Check if transferring to the BASIC area
1517 | LDA BLOCKPTR
1518 | CMP #$01
1519 | BNE +
1520 | LDA BLOCKPTR + 1
1521 | CMP #$10
1522 | BNE +
1523 | CLC
1524 | TYA
1525 | ADC BLOCKPTR
1526 | STA $2D
1527 | TXA
1528 | ADC BLOCKPTR+1
1529 | STA $2E ; Update Start of BASIC variables pointer
1530 |
1531 | _Cmd82 ;Alternative entry point
1532 | + DEY
1533 | CPY #$FF
1534 | BNE +
1535 | DEX
1536 | + STY BYTECNT
1537 | STX BYTECNT + 1
1538 | LDA $FF19
1539 | STA BORDERCLR
1540 | LDA BLOCKPTR ; Copy BLOCKPTR pointer to C82Loop
1541 | STA C82Addr + 1
1542 | LDA BLOCKPTR + 1
1543 | STA C82Addr + 2
1544 | LDA #%10100000 ; Disable raster interrupt signals from TED
1545 | STA $FF0A
1546 | SEI ; Disable IRQs
1547 |
1548 | - LDA $FF1D
1549 | CMP #204
1550 | BNE - ; Waits for raster line 204
1551 |
1552 | LDA $FF06 ; Disables TED screen
1553 | C82enable
1554 | AND #%01101111
1555 | STA $FF06
1556 |
1557 | C82Loop
1558 | ; Timeout counter
1559 | LDA #$0A ; Count ~5.66 seconds
1560 | STA TEMPCNT2 ; H
1561 | LDA #$00 ; 0
1562 | STA TEMPCNT1 ; L
1563 |
1564 | - JSR ReadByte ; Receive a character from RS232
1565 | BCS ++ ; Byte received -> +
1566 | LDA TEMPCNT1 ; Decrement counter
1567 | BNE +
1568 | LDA TEMPCNT2
1569 | BEQ C82End ; Zero, exit
1570 | DEC TEMPCNT2
1571 | + DEC TEMPCNT1
1572 | BCC - ; Keep receiving
1573 |
1574 | ; BCC - ; Nothing received, retry
1575 | ++ LDA RXBYTE ; Store it in RAM
1576 | C82Addr
1577 | STA C82Addr ; (self-modifying code) (WAS BUFFER)
1578 | C82FX
1579 | INC $FF19 ;<<<<
1580 | INC C82Addr + 1 ; 6 Increment the memory pointer
1581 | BNE C82Next ; 2
1582 | INC C82Addr + 2 ; 6
1583 | C82Next ; 1 if coming from the BNE
1584 | LDA BYTECNT ; 4
1585 | BNE + ; 2+1
1586 | LDA BYTECNT+1 ; 4
1587 | BEQ C82End ; 2+1
1588 | DEC BYTECNT+1 ; 6
1589 | + DEC BYTECNT ; 6
1590 | ; LDY BYTECNT
1591 | ; DEY
1592 | ; CPY #$FF
1593 | ; BNE C82Cont
1594 | ; LDX BYTECNT+1
1595 | ; DEX
1596 | ; CPX #$FF
1597 | ; BEQ C82End ; 2
1598 | ; STX BYTECNT+1
1599 | C82Cont ; 1 if coming from the BNE
1600 | ; STY BYTECNT
1601 | LDA C82FX
1602 | EOR #$20 ; Toggle INC <-> DEC
1603 | STA C82FX
1604 | JMP C82Loop
1605 | C82End
1606 | LDA BORDERCLR
1607 | STA $FF19
1608 | ;LDA $DC0D ; Clear the interrupt flags ***
1609 |
1610 | LDA $FF06 ; Enable screen
1611 | ORA #%00010000
1612 | STA $FF06
1613 | LDA #$02
1614 | STA $FF0A ; Enable raster interrupts
1615 | CLI ; Enable IRQs
1616 | RTS
1617 |
1618 | ;///////////////////////////////////////////////////////////////////////////////////
1619 | ; 131: PCM audio streaming until receiving a NUL ($00) character
1620 |
1621 | Cmd83
1622 | SEI
1623 |
1624 | LDA $FF19
1625 | STA BORDERCLR
1626 |
1627 | LDX #$88
1628 |
1629 | - LDA $FF1D
1630 | CMP #251
1631 | BNE - ; Wait for raster line 251
1632 |
1633 | LDA $FF06 ; Disable TED screen
1634 | AND #%01101111
1635 | STA $FF06
1636 |
1637 | JSR TurboRX ; Do the thing
1638 | CLI
1639 |
1640 |
1641 | LDA $FF06 ; Enable TED screen
1642 | ORA #%00010000
1643 | STA $FF06
1644 | LDA #$82
1645 | STA $FF09 ; Ack raster interrupts
1646 |
1647 |
1648 | LDA BORDERCLR
1649 | STA $FF19
1650 | RTS
1651 |
1652 | ;////////////////////////////////////////////////////////////////////////////////////
1653 | ; 134: Start a file transfer
1654 | Cmd86
1655 | SEI
1656 | +DisROMs
1657 | JSR _Cmd86
1658 | +EnROMs
1659 | CLI
1660 | JMP CmdFE ; Exit command mode
1661 |
1662 |
1663 | ;///////////////////////////////////////////////////////////////////////////////////
1664 | ; 144: Returns to the default text mode, requires 3 parameter bytes
1665 | ; Page (not used), border color, background color
1666 |
1667 | Cmd90
1668 | JSR GetFromPrBuffer ; Reads a byte from the print buffer
1669 | ;Página - Descartado
1670 | JSR GetFromPrBuffer ; Reads a byte from the print buffer
1671 | STA $FF19
1672 | JSR GetFromPrBuffer ; Reads a byte from the print buffer
1673 | STA $FF15
1674 | _txtmode
1675 | LDA #%00011011 ; Switch to text mode
1676 | STA $FF06
1677 | LDA #$00
1678 | STA $83
1679 | LDA $FF07 ; Disable multicolor mode
1680 | AND #$48
1681 | STA $FF07
1682 | LDA #$08 ; Attrs at $0800 Screen at $0C00
1683 | STA $FF14
1684 | LDA $FF13 ; Charset at $D400
1685 | AND #$03
1686 | ORA #$D4
1687 | STA $FF13
1688 | LDA $FF12 ; Read Charset from ROM
1689 | ORA #$04
1690 | STA $FF12
1691 |
1692 | RTS
1693 |
1694 | ;///////////////////////////////////////////////////////////////////////////////////
1695 | ; 145: Switch to bitmap hires mode, requires 2 parameter bytes
1696 | ; Page (not used), border color
1697 |
1698 | Cmd91
1699 | JSR GetFromPrBuffer ; Reads a byte from the print buffer
1700 | JSR GetFromPrBuffer ; Reads a byte from the print buffer
1701 | STA $FF19
1702 | JSR _luchcopy
1703 | ; LDA #$08 ; Attributes at $0800
1704 | LDA #$18 ; Attributes at $1800
1705 | STA $FF14
1706 | LDA $FF12
1707 | AND #$03 ;$07
1708 | ORA #$08
1709 | STA $FF12 ; Bitmap at $2000
1710 | LDA $FF07 ; Disable multicolor mode
1711 | AND #$48
1712 | STA $FF07
1713 | ; Switch to bitmap mode
1714 | LDA #%00111011
1715 | STA $FF06
1716 | STA $83
1717 | RTS
1718 |
1719 | ; Copy color and luma tables from $800 to $1800 before switching to graphic modes
1720 | _luchcopy
1721 | LDX #$00
1722 | - LDA $0800,X ; Lumas
1723 | STA $1800,X
1724 | LDA $0900,X
1725 | STA $1900,X
1726 | LDA $0A00,X
1727 | STA $1A00,X
1728 | LDA $0B00,X
1729 | STA $1B00,X
1730 | LDA $0C00,X ; colors
1731 | STA $1C00,X
1732 | LDA $0D00,X
1733 | STA $1D00,X
1734 | LDA $0E00,X
1735 | STA $1E00,X
1736 | LDA $0F00,X
1737 | STA $1F00,X
1738 | INX
1739 | BNE -
1740 | RTS
1741 |
1742 | ;///////////////////////////////////////////////////////////////////////////////////
1743 | ; 146: Switch to bitmap multicolor mode, requires 4 parameter bytes
1744 | ; Page (not used), border color, background color, multicolor 3 color
1745 |
1746 | Cmd92
1747 | JSR GetFromPrBuffer ; Reads a byte from the print buffer
1748 | JSR GetFromPrBuffer ; Reads a byte from the print buffer
1749 | STA $FF19
1750 | JSR GetFromPrBuffer ; Reads a byte from the print buffer
1751 | STA $FF15
1752 | JSR GetFromPrBuffer ; Reads a byte from the print buffer
1753 | STA $FF16
1754 | JSR _luchcopy
1755 | ; LDA #$08 ; Attributes at $0800
1756 | LDA #$18 ; Attributes at $1800
1757 | STA $FF14
1758 | LDA $FF12
1759 | AND #$03
1760 | ORA #$08
1761 | STA $FF12 ; Bitmap at $2000
1762 | LDA #$10 ; Set multicolor multicolor mode
1763 | ORA $FF07
1764 | STA $FF07
1765 | ; Switch to bitmap mode
1766 | LDA #%00111011
1767 | STA $FF06
1768 | STA $83
1769 | RTS
1770 |
1771 | ;///////////////////////////////////////////////////////////////////////////////////
1772 | ; 152: Clears the graphic screen
1773 | Cmd98
1774 | JMP $C567 ;SCNCLR
1775 | ; RTS
1776 |
1777 | ;///////////////////////////////////////////////////////////////////////////////////
1778 | ; 153: Set Pen color
1779 | ; Parameters: Pen, Color
1780 | Cmd99:
1781 | JSR GetFromPrBuffer ; Pen
1782 | TAY ; Save it
1783 | JSR GetFromPrBuffer ; Color
1784 | TAX
1785 | TYA
1786 | BNE +
1787 | STX $FF15 ; Pen 0
1788 | STX UPBGC
1789 | RTS
1790 | + CMP #$01
1791 | BNE +
1792 | STX $86 ; Pen 1
1793 | RTS
1794 | + CMP #$02
1795 | BNE +
1796 | STX $85 ; Pen 2
1797 | RTS
1798 | + CMP #$03
1799 | BNE +
1800 | STX $FF16 ; Pen 3
1801 | + RTS
1802 |
1803 | ;///////////////////////////////////////////////////////////////////////////////////
1804 | ; 154: Plot point
1805 | ; Parameters: Pen, X(16bit), Y(16bit)
1806 | Cmd9A:
1807 | JSR GetFromPrBuffer ; Pen
1808 | STA $84
1809 | LDY #$00
1810 | - JSR GetFromPrBuffer ; Get coordinates
1811 | STA $02AD,Y
1812 | INY
1813 | CPY #$04
1814 | BNE -
1815 | LDA $FF06
1816 | AND #$20
1817 | BEQ + ; Bitmap mode?
1818 | SEI
1819 | JSR $C1A5 ; Plot point
1820 | CLI
1821 | + RTS
1822 |
1823 | ;///////////////////////////////////////////////////////////////////////////////////
1824 | ; 155: Line
1825 | ; Parameters: Pen, X1(16bit), Y1(16bit), X2(16bit), Y2(16bit)
1826 | Cmd9B:
1827 | JSR GetFromPrBuffer ; Pen
1828 | STA $84
1829 | LDY #$00
1830 | - JSR GetFromPrBuffer ; Get coordinates
1831 | STA $02AD,Y
1832 | INY
1833 | CPY #$08
1834 | BNE -
1835 | LDA $FF06
1836 | AND #$20
1837 | BEQ + ; Bitmap mode?
1838 | ; SEI
1839 | JSR $C0DA ; Draw line
1840 | ; CLI
1841 | + RTS
1842 |
1843 | ;///////////////////////////////////////////////////////////////////////////////////
1844 | ; 156: Box
1845 | ; Parameters: Pen, X1(16bit), Y1(16bit), X2(16bit), Y2(16bit), Fill
1846 | Cmd9C:
1847 | JSR GetFromPrBuffer ; Pen
1848 | STA $84
1849 | LDY #$00
1850 | STY $02D0 ; Rotation lo
1851 | STY $02D1 ; Rotation hi
1852 | - JSR GetFromPrBuffer
1853 | STA $02CC,Y ; X1, Y1
1854 | INY
1855 | CPY #$04
1856 | BNE -
1857 | ; LDY #$00
1858 | - JSR GetFromPrBuffer
1859 | STA $02D4,Y ; X2, Y2
1860 | INY
1861 | CPY #$08
1862 | BNE -
1863 | JSR GetFromPrBuffer ; Fill flag
1864 | BEQ +
1865 | LDA #$01
1866 | + TAX
1867 | JMP $BB02
1868 | ; RTS
1869 |
1870 | ;///////////////////////////////////////////////////////////////////////////////////
1871 | ; 157: Circle
1872 | ; Parameters: Pen, center X(16bit), center Y(16bit), radius X(16bit), radius Y(16bit)
1873 | Cmd9D:
1874 | JSR GetFromPrBuffer ; Pen
1875 | STA $84
1876 | LDY #$00
1877 | STY $02D8 ; Start angle lo
1878 | STY $02D9 ; Start angle hi
1879 | - JSR GetFromPrBuffer
1880 | STA $02CC,Y ; center X, Y. radius X, Y
1881 | INY
1882 | CPY #$08
1883 | BNE -
1884 | LDA #$68
1885 | STA $02DA ; End angle lo
1886 | LDX #$01
1887 | STX $02DB ; End angle hi
1888 | INX
1889 | STX $E9 ; Segment angle
1890 |
1891 | ; This section adapted from Plus4 ROM
1892 | LDX #$2D
1893 | LDY #$2B
1894 | JSR $C305 ; Subtract to coordinates
1895 | BCC +
1896 | + LDX #$03
1897 | - LDA $02D0,x
1898 | STA $02D4,x
1899 | DEX
1900 | BPL -
1901 | LDA #$90
1902 | JSR $BCD5 ; ???
1903 | LDX #$07
1904 | - LDA $02D0,x
1905 | STA $02DC,x
1906 | DEX
1907 | BPL -
1908 | JSR $BCEE ; ???
1909 | JSR $C37B ; Set graphic cursor
1910 | CLC
1911 | JMP $C0B2 ; Circle
1912 | ; RTS
1913 |
1914 | ;///////////////////////////////////////////////////////////////////////////////////
1915 | ; 158: Fill
1916 | ; Parameters: Pen, X(16bit), Y(16bit)
1917 | Cmd9E:
1918 | JSR GetFromPrBuffer ; Pen
1919 | STA $84
1920 | LDY #$00
1921 | - JSR GetFromPrBuffer ; Get coordinates
1922 | STA $02AD,Y
1923 | STA $02B1,Y
1924 | INY
1925 | CPY #$04
1926 | BNE -
1927 | LDA #$00 ; fill area enclosed by the pen number
1928 | JMP $B8E7 ; PAINT
1929 | ; RTS
1930 |
1931 | ;///////////////////////////////////////////////////////////////////////////////////
1932 | ; 160: Selects the screen as the output for the received characters
1933 | CmdA0
1934 | LDA FLAGS1
1935 | AND #%10111111 ; Switch to screen mode, Setting FLAGS1 bit 6 to 0
1936 | STA FLAGS1 ; and exits command mode
1937 | JMP CmdFE
1938 |
1939 | ;///////////////////////////////////////////////////////////////////////////////////
1940 | ; 161: Selects the voice synthesizer as output for the received characters
1941 | CmdA1
1942 | LDA FLAGS1
1943 | ORA #%01000000 ; Switch to voice mode, Setting FLAGS1 bit 6 to 1
1944 | STA FLAGS1 ; and exits command mode
1945 | JMP CmdFE
1946 |
1947 | ;///////////////////////////////////////////////////////////////////////////////////
1948 | ; 162: Requests the terminal's ID and version
1949 |
1950 | CmdA2
1951 | SEI
1952 | LDY #00
1953 | - LDA IDString,Y
1954 | JSR SendID
1955 | INY
1956 | CPY #24
1957 | BNE -
1958 | CLI
1959 | RTS ;JMP ExitIrq
1960 |
1961 | ;///////////////////////////////////////////////////////////////////////////////////
1962 | ; 163: Queries terminal if a command is implemented, requires 1 parameter: Command #
1963 | ; Returns number of parameters if command exist, or bit-7 = 1 if not.
1964 |
1965 | CmdA3
1966 | JSR GetFromPrBuffer ; Reads a byte from the print buffer / Command #
1967 | SEI
1968 | BPL + ; If it's not a command, replace with unimplemented command ($8F)
1969 | CMP #MAXCMD+1
1970 | BCC ++ ; Is it less than or equal to the highest implemented command?
1971 | + LDA #$8F ; Invalid command, replace with unimplemented command ($8F)
1972 | ++ AND #%01111111 ; -128
1973 | TAY
1974 | LDA CmdParTable,Y ; Get parameter count/Command implemented
1975 | JSR SendID
1976 | CLI
1977 | RTS
1978 |
1979 | ;////////////////////////////////////////////////////////////////////////////////////
1980 | ; 164: Query client's setup, requires one parameter: subsystem
1981 |
1982 | CmdA4
1983 | JSR GetFromPrBuffer ; Reads byte from the print buffer / Subsystem
1984 | SEI
1985 | +DisROMs
1986 | CMP #$06 ; Check if valid subsystem
1987 | BCC .a4_0 ; less than...
1988 | BEQ .a4_0 ; equal...
1989 | LDA #$07
1990 | .a4_0
1991 | TAY
1992 | LDA A4offsets,Y ; A: A4array offset
1993 | TAY
1994 | LDA A4array,Y ; A: responte length
1995 | TAX
1996 | INX
1997 |
1998 | .a4_1
1999 | JSR SendID
2000 | INY
2001 | LDA A4array,Y
2002 | DEX
2003 | BNE .a4_1
2004 | +EnROMs
2005 | CLI
2006 | RTS
2007 |
2008 | ;///////////////////////////////////////////////////////////////////////////////////
2009 | ; 176: Sets cursor position, requires two parameter bytes: Column, row
2010 | ; Relative to the current text window
2011 |
2012 | CmdB0
2013 | JSR StopCRSR
2014 | JSR GetFromPrBuffer ; Reads a byte from the print buffer / Column
2015 | CMP #39 ; Greater than 39?
2016 | BCC + ; No, save it, get row
2017 | LDA #39 ; Yes, force 39
2018 | + PHA ; temp save
2019 | JSR GetFromPrBuffer ; Reads a byte from the print buffer / Row
2020 | CLC
2021 | ADC WTOP
2022 | TAX
2023 | CPX WBOTTOM ; Greater than WBOTTOM?
2024 | BCC + ; No, continue
2025 | LDX WBOTTOM ; Yes, force WBOTTOM
2026 | + PLA
2027 | TAY ;LDY TEMP1
2028 | CLC
2029 | JSR $D839 ; Set cursor position
2030 | JSR StartCRSR
2031 | LDA WTOP ; Restore OS text window limits
2032 | STA $07E6
2033 | LDX WBOTTOM
2034 | DEX
2035 | STX $07E5
2036 | JSR $DE80 ; Rebuild link table
2037 | JMP CmdFE ; Exit command mode
2038 |
2039 | ;///////////////////////////////////////////////////////////////////////////////////
2040 | ; 177: Fill a row with the selected character (screen code) cursor is not moved
2041 | ; Requires 2 parameter bytes: Row, screen_code
2042 |
2043 | CmdB1
2044 | JSR StopCRSR
2045 | JSR GetFromPrBuffer ; Reads a byte from the print buffer / Row
2046 | CMP #$24 ; Greater than 24?
2047 | BCC + ; No, continue
2048 | LDA #$24 ; Yes, force 24
2049 | + TAX
2050 | LDA $D802,X ; Get the row address low byte from the ROM table
2051 | STA .cb11+1 ; Screen
2052 | STA .cb12+1 ; Attributes
2053 | LDA $D81B,X ; Row address high byte
2054 | STA .cb11+2 ; Screen
2055 | EOR #$04
2056 | STA .cb12+2 ; Attributes
2057 |
2058 | JSR GetFromPrBuffer ; Reads a byte from the print buffer / screen_code
2059 |
2060 | TAY ; Save screen_code
2061 |
2062 | ; Fill row
2063 | LDX #39
2064 | .cb11
2065 | STA $0C00,X
2066 | LDA $053B ; Current Color
2067 | ;ORA $053C ; Flash
2068 | .cb12
2069 | STA $0800,X
2070 | TYA
2071 | DEX
2072 | BPL .cb11
2073 |
2074 | JMP StartCRSR
2075 |
2076 | ; RTS
2077 |
2078 | ;///////////////////////////////////////////////////////////////////////////////////
2079 | ; 178: Set the cursor enable status, requires a single parameter byte
2080 |
2081 | CmdB2
2082 | LDA FLAGS1
2083 | ORA #%00001000
2084 | TAY
2085 | JSR GetFromPrBuffer ; Reads a byte from the print buffer
2086 | BNE CrSr00 ; IF not $00 continue on CrSr00
2087 | JSR StopCRSR
2088 | LDA FLAGS1
2089 | AND #%11110111
2090 | TAY
2091 | CrSr00
2092 | STY FLAGS1
2093 | RTS ;JMP ExitIrq
2094 |
2095 | ;///////////////////////////////////////////////////////////////////////////////////
2096 | ; 179: Split screen, requires 2 parameters, mode/row and background colors
2097 |
2098 | UPBGC:
2099 | !byte $00 ; Background color for the upper part of the split
2100 | BTBGC:
2101 | !byte $00 ; Background color for the bottom part of the split
2102 | VMODE:
2103 | !byte $00 ; Video mode for the upper part of the split
2104 |
2105 | ;---------------------------------
2106 | ; Split screen interrupt routine
2107 |
2108 | IrqB3:
2109 | LDY BTBGC
2110 | LDA #$08 ; Attributes at $0800
2111 | STA $FF14
2112 | LDA $FF12 ; Charset from ROM
2113 | ORA #$04
2114 |
2115 | ; Watch for page boundaries!
2116 | LDX #$0D ;2
2117 | - DEX ;2
2118 | BNE - ;3
2119 | TAX
2120 |
2121 | ; NOP
2122 | ; NOP
2123 | ; NOP
2124 | STY $FF15 ;4 Bottom section background color
2125 | LDA #%00011011 ;2 Text mode
2126 | STA $FF06 ;4
2127 | LDA $FF07 ;4
2128 | AND #%11101111 ;2
2129 | STA $FF07 ;4 Disable multicolor
2130 | STX $FF12
2131 |
2132 | LDA #204 ;2
2133 | STA $FF0B ;4
2134 |
2135 | LDA #%10000010 ; Limpia todas las banderas de interrupcion, incluyendo la de interrupcion de barrido
2136 | STA $FF09
2137 | LDA #%10100010 ; Enable raster interrupt signals from TED, and clear MSB in TED's raster register
2138 | STA $FF0A
2139 |
2140 | LDA #Irq
2143 | STA $0315
2144 |
2145 | JMP $FCBE
2146 |
2147 | CmdB3
2148 | JSR GetFromPrBuffer
2149 | BEQ b3cancel
2150 | TAY
2151 | BMI +
2152 | LDX #$00
2153 | BEQ ++
2154 | + LDX #$10
2155 | ++ STX VMODE
2156 | AND #$1F ; Remove mode bit
2157 | STA WTOP ; Set text window
2158 | STA $88 ; Limit for drawing routines
2159 | ASL
2160 | ASL
2161 | ASL ; .A*8
2162 | CLC
2163 | ADC #$01 ; +01 = Scanline-3
2164 | STA SPLITRST
2165 | JSR GetFromPrBuffer
2166 | STA UPBGC ; This is wrong, we need 1 byte per bg color
2167 | TAX
2168 | TYA
2169 | AND #$20 ; Check if there's additional parameters
2170 | BEQ +
2171 | LDA #$42 ; Get 2 more parameters
2172 | STA CMDFlags
2173 | JSR GetFromPrBuffer
2174 | STA BTBGC
2175 | JSR GetFromPrBuffer
2176 | AND #$7F
2177 | STA $FF16
2178 | BPL ++
2179 | + TXA
2180 | LSR
2181 | LSR
2182 | LSR
2183 | LSR
2184 | STA BTBGC
2185 | ++ LDA #%00010000
2186 | ORA FLAGS1
2187 | STA FLAGS1
2188 | LDY #$00
2189 | LDX WTOP
2190 | CLC
2191 | JSR $D839 ; Set cursor position
2192 | LDA WTOP
2193 | STA $07E6
2194 | LDA $FF12
2195 | AND #$03
2196 | ORA #$08
2197 | STA $FF12 ; Bitmap at $2000
2198 | JSR _luchcopy ; Copy luma/colors to $1800
2199 | ; LDA #$03
2200 | ; STA ReadBLoop-1 ; Limit reception to 3 characters per frame
2201 | RTS
2202 | b3cancel ; Cancel split screen
2203 | JSR GetFromPrBuffer
2204 | b3cancel2
2205 | LDA #%11101111
2206 | AND FLAGS1
2207 | STA FLAGS1
2208 | LDA #$00
2209 | STA WTOP ; Set text window
2210 | STA $07E6
2211 | LDA #$19
2212 | STA $88 ; Max lines for drawing routines
2213 | ; LDA #$03
2214 | ; STA ReadBLoop-1
2215 | RTS
2216 |
2217 | ;///////////////////////////////////////////////////////////////////////////////////
2218 | ; 180: Get cursor position, returns 2 bytes, column and row. Exit CMD mode
2219 |
2220 | CmdB4
2221 | SEI
2222 | SEC
2223 | JSR $D839 ; Get cursor position
2224 | TXA
2225 | SEC
2226 | SBC WTOP
2227 | PHA
2228 | TYA ; Column
2229 | SEC
2230 | SBC WTOP
2231 | JSR SendID
2232 | PLA ; Row
2233 | JSR SendID
2234 | CLI
2235 | LDA WTOP ; Restore text window limits
2236 | STA $07E6
2237 | LDX WBOTTOM
2238 | DEX
2239 | STX $07E5
2240 | JMP CmdFE
2241 |
2242 | ;///////////////////////////////////////////////////////////////////////////////////
2243 | ; 181: Set text window, requires 2 parameters, top and bottom rows
2244 |
2245 | CmdB5
2246 | JSR GetFromPrBuffer
2247 | BPL +
2248 | LDA #$00
2249 | + CMP #24
2250 | BCC +
2251 | LDA #24
2252 | + STA WTOP
2253 | JSR GetFromPrBuffer
2254 | TAY
2255 | BPL +
2256 | LDY #$00
2257 | + CPY #24
2258 | BCC +
2259 | LDY #24
2260 | + INY
2261 | STY WBOTTOM
2262 | LDY #$00
2263 | LDX WTOP
2264 | CLC
2265 | JSR $D839 ; Set cursor position
2266 | LDA WTOP ; Set OS text window limits
2267 | STA $07E6
2268 | LDX WBOTTOM
2269 | DEX
2270 | STX $07E5
2271 | RTS
2272 |
2273 | ;///////////////////////////////////////////////////////////////////////////////////
2274 | ; 182: Scroll text window, requires 1 parameter: rows to scroll, signed byte
2275 | CmdB6
2276 | JSR GetFromPrBuffer
2277 | BEQ ++
2278 | BPL +
2279 | ;Scroll up
2280 | EOR #$FF
2281 | STA $D8
2282 | INC $D8
2283 | - JSR $DF04
2284 | DEC $D8
2285 | BNE -
2286 | BEQ ++
2287 | + STA $D8
2288 | - JSR $DEF6
2289 | DEC $D8
2290 | BNE -
2291 |
2292 | ++ RTS
2293 |
2294 | ;///////////////////////////////////////////////////////////////////////////////////
2295 | ; 183: Set Ink color, requires 1 parameter: Color index
2296 | CmdB7
2297 | JSR GetFromPrBuffer
2298 | AND #$7F ; Remove Flash bit
2299 | STA $053B
2300 | JMP CmdFE
2301 |
2302 | ;///////////////////////////////////////////////////////////////////////////////////
2303 | ; 254: Exit command mode, setting FLAGS1 bit 7 to 0
2304 | CmdFE
2305 | LDA FLAGS1
2306 | AND #%01111111
2307 | STA FLAGS1
2308 | RTS
2309 |
2310 | ;///////////////////////////////////////////////////////////////////////////////////
2311 |
2312 | SendID
2313 | STA ACIADATA ; Store the character in the transmit register
2314 | LDA #%00001011 ; no parity, no echo, no tx irq (rts=0, receive enable), no rx irq, rx enabled (dtr=0)
2315 | STA ACIACOMMAND
2316 | - LDA ACIASTATUS ; Wait for the character to be transmitted
2317 | AND #%00010000
2318 | BEQ -
2319 | LDA #%00000011 ; no parity, no echo, no tx irq (rts=1, receive disable), no rx irq, rx enabled (dtr=0)
2320 | STA ACIACOMMAND
2321 | RTS
2322 |
2323 | ; Commands routine pointer table, unimplemented commands point to CMDOFF
2324 | CmdTable:
2325 | !word Cmd80,Cmd81,Cmd82,Cmd83,CmdFE,CmdFE,Cmd86,CmdFE,CmdFE,CmdFE,CmdFE,CmdFE,CmdFE,CmdFE,CmdFE,CmdFE
2326 | !word Cmd90,Cmd91,Cmd92,CmdFE,CmdFE,CmdFE,CmdFE,CmdFE,Cmd98,Cmd99,Cmd9A,Cmd9B,Cmd9C,Cmd9D,Cmd9E,CmdFE
2327 | !word CmdA0,CmdA1,CmdA2,CmdA3,CmdA4,CmdFE,CmdFE,CmdFE,CmdFE,CmdFE,CmdFE,CmdFE,CmdFE,CmdFE,CmdFE,CmdFE
2328 | !word CmdB0,CmdB1,CmdB2,CmdB3,CmdB4,CmdB5,CmdB6,CmdB7
2329 |
2330 | ; Command parameter number table.
2331 | ; bit-7 = 1 : Parameter not implemented
2332 | CmdParTable:
2333 | !byte $02 ,$01 ,$02 ,$00 ,$80 ,$80 ,$00 ,$80 ,$80 ,$80 ,$80 ,$80 ,$80 ,$80 ,$80 ,$80
2334 | !byte $03 ,$02 ,$04 ,$80 ,$80 ,$80 ,$80 ,$80 ,$00 ,$02 ,$05 ,$09 ,$0A ,$09 ,$05 ,$80
2335 | !byte $00 ,$00 ,$00 ,$01 ,$01 ,$80 ,$80 ,$80 ,$80 ,$80 ,$80 ,$80 ,$80 ,$80 ,$80 ,$80
2336 | !byte $02 ,$02 ,$01 ,$02 ,$00 ,$02 ,$01 ,$01
2337 |
2338 | InitScr
2339 | !byte $93, $08, $0E, $00
2340 | RetroIntro
2341 | !text " rETROCOMPUTACION PRESENTS"
2342 | !byte 13, 13, 29, 29, 29, 29, 29, 29, 29, 29
2343 | !text " rETROTERM pLUS/4"
2344 | !byte 19, 0
2345 | Version
2346 | !byte $05, $93, $99, $08, $0E
2347 | !text "retroterm plus/4 VER "
2348 | +_Version_
2349 | !fill 34-(*-Version),$20 ; Auto space fill
2350 | !text "19200,8n1"
2351 | !byte $05, $0D , $00
2352 | Msg06
2353 | !text "(c)2025 RETROCOMPUTACION.COM"
2354 | !byte $0D
2355 | !byte $9A
2356 | !text "turbo56k V0.8"
2357 | !byte $0D, $05, $00
2358 | ExitMsg
2359 | !byte $93, $8E
2360 | !text "EXITING TO BASIC..."
2361 | !byte $0D
2362 | !text "SYS28672 TO RESTART RETROTERM"
2363 | !byte $0D, $0D, $00
2364 |
2365 | IDString: ; ID String 22 characters long
2366 | !text "RTRETROTERM-P4 "
2367 | +_Version_
2368 | !fill 22-(*-IDString),$20 ; Auto space fill
2369 | !byte $00,$08 ;Turbo56K version, subversion
2370 |
2371 | Palette
2372 | !byte $00,$71,$32,$63,$34,$45,$26,$67
2373 | !byte $48,$29,$52,$31,$41,$65,$46,$51
2374 | ;$FF15 background, $FF19 border
2375 |
2376 | FTable
2377 | !byte $85,$89,$86,$8A,$87,$8B,$88,$8C
2378 |
2379 | ;///////////////////////////////////////////////////////////////////////////////////
2380 | ; Buffer de impresion
2381 | ;///////////////////////////////////////////////////////////////////////////////////
2382 |
2383 | ENDOFCODE
2384 | !if ENDOFCODE > $7EFF {
2385 | !error "ERROR - Part 1 data beyond $7EFF"
2386 | }
2387 | }
2388 | _ENDOFCODE_
2389 |
2390 | ;///////////////////////////////////////////////////////////////////////////////////
2391 | ; Mobile code section $8000->
2392 | ;///////////////////////////////////////////////////////////////////////////////////
2393 | _SHADOWCODE_
2394 | !pseudopc $8000{
2395 | SHADOWCODE:
2396 |
2397 | ; ------------------------------------------
2398 | ; Save to disk routines
2399 | CRC = $0F40 ;$FD ; CRC result $FD/$FE
2400 | CRCHI = $1900 ; CRC tables
2401 | CRCLO = $1A00
2402 | FNAME = $0332 ; Null terminated file name
2403 | FNL = $03F2 ; Filename length
2404 |
2405 | ; Copy Memory
2406 | ; Source at SOURCEPTR($D8/$D9)
2407 | ; Destination at DESTPTR($DA/$DB)
2408 | ; Size at CSIZE($58/$59)
2409 | CSIZE = $E8
2410 | SOURCEPTR = $D8
2411 | DESTPTR = $DA
2412 |
2413 | ; List of detected drives. Filled at first startup
2414 | DRIVES:
2415 | !fill $08,$FF
2416 |
2417 | _MemCpy
2418 | -- LDY #$00
2419 | - LDA (SOURCEPTR),Y
2420 | STA (DESTPTR),Y
2421 | LDA CSIZE
2422 | BNE +
2423 | LDA CSIZE+1
2424 | BEQ ++
2425 | DEC CSIZE+1
2426 | + DEC CSIZE
2427 | INY
2428 | BNE -
2429 |
2430 | INC SOURCEPTR+1
2431 | INC DESTPTR+1
2432 | BNE --
2433 | ++ RTS
2434 |
2435 | _Cmd86
2436 | JSR MAKECRCTABLE
2437 |
2438 | DESTADDR = $1B00
2439 | BBUF = $0E00
2440 |
2441 | ; Copy routine to lower RAM ($1B00)
2442 | LDX #$01
2443 | - LDA _86data,X
2444 | STA SOURCEPTR,X
2445 | LDA _86data+2,X
2446 | STA DESTPTR,X
2447 | LDA _86data+4,X
2448 | STA CSIZE,X
2449 | DEX
2450 | BPL -
2451 |
2452 | JSR _MemCpy ; Do mem copy
2453 | LDX #$08
2454 | - LDA DRIVES,X ; Copy list of detected drives to low RAM
2455 | STA _drives,X
2456 | DEX
2457 | BPL -
2458 | JMP bsave
2459 | _86data
2460 | !word _bsstart,DESTADDR,_bsend-_bsstart
2461 |
2462 | _bsstart:
2463 | !pseudopc $1B00{
2464 | bsave:
2465 | +EnROMs
2466 | LDA #$00
2467 | STA $FF19
2468 | STA $FF15
2469 | JSR b3cancel2 ; Cancel split screen
2470 |
2471 | CLI
2472 | ; Print message
2473 | +StringOut bst1
2474 | ; SEI
2475 | ; - LDA $FF1D
2476 | ; CMP #251
2477 | ; BNE - ; Waits for raster line 251
2478 | ; JSR ReadByte ; Get file type
2479 | ; BCC-
2480 | ; CLI
2481 | ; LDA RXBYTE
2482 | LDA #$46
2483 | STA CMDFlags ; Enable reception
2484 | JSR GetFromPrBuffer ; Get file type
2485 |
2486 | STA $02
2487 | BMI + ; Bit 7 = 1 : PRG, else SEQ
2488 | LDA #bst5
2491 | STA .ft+2
2492 | LDY #>bst3
2493 | LDA #bst4
2498 | STA .ft+2
2499 | LDA #bst2
2501 | ++ JSR STROUT
2502 | +StringOut bst1a
2503 | JSR ReadString ; Get filename
2504 | +SetCursor $0A,$01
2505 | ; Print filename
2506 | +StringOut FNAME
2507 | +SetCursor $20,$0B
2508 | ; Print buffer frame
2509 | +StringOut bst6
2510 |
2511 | JSR UBlock ; Print counters
2512 | JSR URetry
2513 |
2514 | LDX #$00
2515 | STX _curdrv ; Find first available drive #
2516 | - CPX #$08
2517 | BEQ ++ ; No available drive found > CANCEL
2518 | LDA _drives,X
2519 | BPL + ; Available drive
2520 | INX
2521 | BNE -
2522 |
2523 | + STX _curdrv ; Store as current drive
2524 | JSR ddrive
2525 |
2526 | - LDA $C6 ; Matrix value for last keypress
2527 | CMP #$19 ; Wait for 'Y'
2528 | BEQ .y1
2529 | CMP #$27 ; Or 'N'
2530 | BNE +
2531 | ++ LDY #$42 ; CANCEL
2532 | BNE .bb
2533 | + CMP #$28 ; '+'
2534 | BNE +
2535 | JSR ndrive ; Get next drive
2536 | JMP -
2537 | + CMP #$2B ; '-'
2538 | BNE -
2539 | JSR pdrive ; Get previous drive
2540 | JMP -
2541 |
2542 | .y1 ;Continue
2543 | +SetCursor $0B,$08
2544 | +StringOut bst9 ; Print abort message
2545 |
2546 | LDY FNL ; add write string to filename
2547 | LDX #$00
2548 | .ft LDA bst4,X
2549 | STA FNAME,Y
2550 | INY
2551 | INX
2552 | CPX #$04
2553 | BNE .ft
2554 | TXA
2555 | CLC
2556 | ADC FNL
2557 | ;STA FNL
2558 | JSR .bo ; Open file. Input .A = filename length. Returns flag on .Y
2559 | ;LDY #$80 ; OK Flag
2560 |
2561 | ; Read block
2562 | LDA #$00 ; Sound off
2563 | STA $FF11
2564 | .bb
2565 | LDA $C6 ; Keymatrix
2566 | CMP #$03 ; F7?
2567 | BNE +
2568 | LDY #$42 ; ABORT!
2569 | + SEI
2570 | TYA
2571 | JSR SendID
2572 |
2573 | LDY #$03
2574 |
2575 | LDA CMDFlags
2576 | ORA #$44
2577 | STA CMDFlags ; Get 4 parameter bytes
2578 |
2579 | ; Get 4 bytes: Block size LSB,MSB | CRC16 LSB,MSB
2580 |
2581 | CLI
2582 | - JSR GetFromPrBuffer
2583 |
2584 | STA $D8,Y ; $FD/$FE : Size
2585 | DEY
2586 | BPL -
2587 |
2588 | SEI
2589 |
2590 | ; If block size = 0, exit transfer
2591 | LDY $DA
2592 | STY .c+1 ; Set CRC check counter limit
2593 | BNE +
2594 | LDA $DB
2595 | BNE +
2596 | JMP .be ; 0 length -> end transfer
2597 | + LDA #BBUF
2600 | STA BLOCKPTR+1 ; Destination
2601 | LDX $DB
2602 | JSR _Cmd82 ; Receive block
2603 | ; check CRC
2604 | LDY #$FF
2605 | STY CRC
2606 | STY CRC+1
2607 | INY
2608 | - LDA BBUF,Y
2609 | JSR UPDCRC
2610 | INY
2611 | .c CPY #$00
2612 | BNE -
2613 | LDA $D8
2614 | CMP CRC
2615 | BNE .er ; CRC doesn't match, error
2616 | LDA $D9
2617 | CMP CRC+1
2618 | BNE .er ; CRC doesn't match, error
2619 | ; Write to disk
2620 | JSR UBlock
2621 | JSR bwrite ; Write block
2622 | ;LDY #$80 ; OK
2623 | JMP .bb ; Get next block
2624 | .er
2625 | JSR URetry
2626 | LDY #$AA ; ERROR
2627 | JMP .bb ; Retry
2628 |
2629 | ;Open file
2630 | .bo
2631 | ;LDA FNL ; Name length
2632 | LDX #FNAME
2634 | JSR SETNAM ; call SETNAM
2635 |
2636 | LDA _curdrv ; current selected drive
2637 | CLC
2638 | ADC #$08
2639 | TAX
2640 | LDA #$02 ; file number 2
2641 | LDY #$02 ; secondary address 2
2642 | JSR SETLFS ; call SETLFS
2643 | JSR KOPEN ; call OPEN
2644 | BCS .error ; if carry set, file couldnt not be opened
2645 | LDX #$02 ; filenumber 2
2646 | JSR CHKOUT ; call CHKOUT (file 2 now used as output)
2647 | BEQ +
2648 | BNE .error
2649 | + JSR CLRCHN ; CLRCHN
2650 | LDY #$81 ; OK
2651 | RTS
2652 |
2653 | .error ; Handle errors - Cancels transfer
2654 | JSR .bc ; Close file
2655 | LDY #$42 ; CANCEL
2656 | RTS
2657 |
2658 | .bc ; Close file
2659 | LDA #$02
2660 | JSR KCLOSE ; CLOSE
2661 | JMP CLRCHN ; CLRCHN
2662 | ; RTS
2663 |
2664 | .be ; Transfer complete
2665 | JSR .bc ; Close file
2666 | SEI
2667 | +DisROMs
2668 | RTS
2669 |
2670 | bwrite ; Write data
2671 | LDY $DA ; Get counter limit
2672 | STY .b1+1
2673 | LDX #$02 ; filenumber 2
2674 | JSR CHKOUT ; call CHKOUT (file 2 now used as output)
2675 |
2676 | LDY #$00
2677 | - JSR READST ; call READST
2678 | BNE .error ; handle error
2679 | LDA BBUF,Y
2680 | JSR CHROUT ; call CHROUT (write byte to file)
2681 | INY
2682 | .b1 CPY #$00
2683 | BNE -
2684 | JSR CLRCHN ; CLRCHN
2685 | LDY #$81 ; OK
2686 | RTS
2687 |
2688 | ; Quick CRC computation with lookup tables
2689 | UPDCRC:
2690 | EOR CRC+1
2691 | TAX
2692 | LDA CRC
2693 | EOR CRCHI,X
2694 | STA CRC+1
2695 | LDA CRCLO,X
2696 | STA CRC
2697 | RTS
2698 |
2699 | ;Update received block count
2700 | UBlock:
2701 | +SetCursor $00,$06
2702 | +StringOut bst7
2703 | LDA bcount
2704 | LDX bcount+1
2705 | JSR $A45F ; Print number
2706 | INC bcount+1
2707 | BNE +
2708 | INC bcount
2709 | + RTS
2710 |
2711 | bcount
2712 | !byte $00,$00
2713 |
2714 | ;Update retries count
2715 | URetry:
2716 | +SetCursor $00,$07
2717 | +StringOut bst8
2718 | LDA rcount
2719 | LDX rcount+1
2720 | JSR $A45F ; Print number
2721 | INC rcount+1
2722 | BNE +
2723 | INC rcount
2724 | + RTS
2725 |
2726 | rcount
2727 | !byte $00,$00
2728 |
2729 | ;Receive NULL terminated String
2730 | ReadString:
2731 | LDA #$46
2732 | STA CMDFlags
2733 |
2734 |
2735 | LDY #$00
2736 |
2737 | -- INC CMDFlags ; +1 Parameter to read
2738 | JSR GetFromPrBuffer
2739 |
2740 | STA FNAME,Y ; Store name
2741 | BEQ + ; Stop if $00 received
2742 | INY
2743 | CPY #$11
2744 | BNE -- ; Repeat until 16 characters (+ null) are read
2745 | +
2746 | LDA #$00
2747 | STA FNAME,Y ; Make sure the string is NULL terminated
2748 | STY FNL ; String length
2749 | LDA #$40 ; stop reception
2750 | STA CMDFlags
2751 | RTS
2752 |
2753 | ; Find next available drive
2754 | ndrive:
2755 | LDX _curdrv
2756 | - INX
2757 | CPX #$08
2758 | BEQ +
2759 | LDA _drives,X
2760 | BMI -
2761 | STX _curdrv
2762 | + JMP ddrive
2763 | ; RTS
2764 |
2765 | ;Find previous available drive
2766 | pdrive:
2767 | LDX _curdrv
2768 | - DEX
2769 | BMI +
2770 | LDA _drives,X
2771 | BMI -
2772 | STX _curdrv
2773 | + JMP ddrive
2774 | ; RTS
2775 |
2776 | ;Print drive number
2777 | ddrive:
2778 | +SetCursor 11,2
2779 | +StringOut bst10
2780 | CLC
2781 | LDA _curdrv
2782 | ADC #$08
2783 | TAX
2784 | LDA #$00
2785 | JSR $A45F ; Print number
2786 | ; and wait for key release
2787 | - LDA $C6
2788 | CMP #$40
2789 | BNE -
2790 | RTS
2791 |
2792 | ; File save text
2793 | bst1:
2794 | !byte $93,$8E,$99,$92 ; Clear, upp/gfx, light green, rvsoff
2795 | !text "HOST REQUESTED TO SAVE ",$00
2796 | bst1a:
2797 | !text "FILE",$0D
2798 | !text $05,"FILENAME:",$0D
2799 | !text $9E,"TO DRIVE ",$12,"+",$92," ",$12,"-",$0D
2800 | !text $11,$81,"CONTINUE? (Y/N)",$05,$00
2801 | bst2: ; Program
2802 | !text "PROGRAM ",$00
2803 | bst3: ; Sequential
2804 | !text "SEQUENTIAL ",$00
2805 | bst4: ; Write Program
2806 | !text ",P,W"
2807 | bst5: ; Write Sequential
2808 | !text ",S,W"
2809 | ; Buffer frame
2810 | bst6:
2811 | !byte $9E ; Yellow
2812 | !fill $27,$AF ; 39 _
2813 | !byte $BA
2814 | !fill $07,$0D
2815 | !fill $08,$1D ; cursor
2816 | !byte $6F
2817 | !fill $27,$B7 ; 39
2818 | !byte $05, $00 ; White
2819 | ; Block count
2820 | bst7:
2821 | !text "BLOCKS: "
2822 | !fill $05,$9D
2823 | !byte $00
2824 | ; Retry count
2825 | bst8:
2826 | !text "RETRIES: "
2827 | !fill $05,$9D
2828 | !byte $00
2829 | ; Abort text
2830 | bst9:
2831 | !text "HOLD ",$12," F7 ",$92," TO ABORT",$00
2832 | ; Drive clean spaces
2833 | bst10:
2834 | !text " ",$9D,$9D,$00
2835 |
2836 | ; Detected drives copy
2837 | _curdrv:
2838 | !byte $00
2839 | _drives:
2840 | bsend
2841 | }
2842 | _bsend
2843 | ; Generate CRC tables
2844 | MAKECRCTABLE:
2845 | LDX #0 ; X counts from 0 to 255
2846 | BYTELOOP
2847 | LDA #0 ; A contains the low 8 bits of the CRC-16
2848 | STX CRC ; and CRC contains the high 8 bits
2849 | LDY #8 ; Y counts bits in a byte
2850 | BITLOOP
2851 | ASL
2852 | ROL CRC ; Shift CRC left
2853 | BCC NOADD ; Do nothing if no overflow
2854 | EOR #$21 ; else add CRC-16 polynomial $1021
2855 | PHA ; Save low byte
2856 | LDA CRC ; Do high byte
2857 | EOR #$10
2858 | STA CRC
2859 | PLA ; Restore low byte
2860 | NOADD
2861 | DEY
2862 | BNE BITLOOP ; Do next bit
2863 | STA CRCLO,X ; Save CRC into table, low byte
2864 | LDA CRC ; then high byte
2865 | STA CRCHI,X
2866 | INX
2867 | BNE BYTELOOP ; Do next byte
2868 | RTS
2869 |
2870 | ;//////////////////////////
2871 | ; Setup screen
2872 | ;//////////////////////////
2873 | _SETUP
2874 | JSR b3cancel2 ;Cancel split screen
2875 | LDA #suIRQ
2878 | STA $0315
2879 |
2880 | ; Copy routine to lower RAM ($1B00)
2881 | LDX #$01
2882 | - LDA _sudata,X
2883 | STA SOURCEPTR,X
2884 | LDA _sudata+2,X
2885 | STA DESTPTR,X
2886 | LDA _sudata+4,X
2887 | STA CSIZE,X
2888 | DEX
2889 | BPL -
2890 |
2891 | JSR _MemCpy ;Do mem copy
2892 | +DisROMs
2893 | LDA load_drive
2894 | STA _load_drive
2895 | JSR dosetup ;Call setup routine
2896 |
2897 | LDA #Irq
2900 | STA $0315
2901 |
2902 | RTS
2903 |
2904 | _sudata
2905 | !word _sustart,$1B00,_suend-_sustart
2906 | ;----
2907 | _sustart:
2908 | !pseudopc $1B00{
2909 | dosetup:
2910 | +EnROMs
2911 | LDA $FF15 ;Save screen colors
2912 | PHA
2913 | LDA $FF19
2914 | PHA
2915 | LDA $053B
2916 | PHA
2917 |
2918 | _dosetup ; alternative entry point
2919 | LDA #$32
2920 | STA $FF15
2921 | STA $FF19
2922 | LDA #%10100010 ; Enable raster interrupt signals from TED, and clear MSB in TED's raster register
2923 | STA $FF0A
2924 | JSR _txtmode ; Switch to text mode
2925 |
2926 | LDA #24
2927 | STA $07E5
2928 |
2929 | LDA #rate_offs
2932 | STA $D9
2933 |
2934 | JSR set_prefs
2935 | JSR bck_data
2936 |
2937 | CLI
2938 | ;...
2939 | ; Print message
2940 | +StringOut sut1
2941 | +SetCursor $00,$16
2942 | +StringOut sut3
2943 | LDA _load_drive
2944 | BMI +
2945 | +StringOut sut3_
2946 | + LDA #$80
2947 | STA $0540 ; Repeat all keys
2948 |
2949 | JSR refresh_init ; Show modem init string
2950 | JSR show_rate ; Show modem init baud rate
2951 |
2952 | --
2953 | +SetCursor $14,$02
2954 | +StringOut sut2
2955 | LDX rb1l+1
2956 | LDA rb1h+1
2957 |
2958 | JSR $A45F ; Print RTS delay
2959 |
2960 | - JSR $EBDD ; Read keyboard buffer
2961 | BEQ -
2962 | CMP #$2B ; (+)
2963 | BNE +
2964 | INC rb1l+1
2965 | BNE --
2966 | INC rb1h+1
2967 | JMP --
2968 | + CMP #$2D ; (-)
2969 | BNE ++
2970 | LDA rb1l+1
2971 | BNE +
2972 | DEC rb1h+1
2973 | + DEC rb1l+1
2974 | JMP --
2975 |
2976 | ++ CMP #$49 ; (I)
2977 | BNE +
2978 | JSR edit_init
2979 | JMP --
2980 |
2981 | + CMP #$52 ; (R)
2982 | BNE +
2983 | JSR cycle_rates
2984 | JMP --
2985 |
2986 | + CMP #$50 ; (P)
2987 | BNE +
2988 | JMP phone_book
2989 |
2990 | + CMP #$87 ; (F5)
2991 | BNE ++
2992 | LDA _load_drive
2993 | BMI +
2994 | JSR psave
2995 | + JMP --
2996 |
2997 | ++
2998 | CMP #$85 ; (F1)
2999 | BEQ +
3000 | BNE --
3001 | +
3002 | dsexit:
3003 |
3004 | ;....
3005 | LDA #$00
3006 | STA $0540 ; Default key repeat
3007 | SEI
3008 | LDX #$EA
3009 | - LDA _sudtmp+4,X
3010 | STA setupdata+4,X
3011 | DEX
3012 | BPL -
3013 | JSR data_bck
3014 | JSR _resp ; copy new prefs to setupdata
3015 |
3016 | LDA #%10100000 ; Disable raster interrupt signals from TED
3017 | STA $FF0A
3018 |
3019 | PLA
3020 | STA $053B
3021 | PLA
3022 | STA $FF19 ; Restore screen colors
3023 | PLA
3024 | STA $FF15
3025 | JSR $D88B ; Clear screen
3026 | +DisROMs
3027 | RTS
3028 |
3029 | ; --- Minimal IRQ
3030 | suIRQ:
3031 |
3032 | PHA ; store register A in stack
3033 | TXA
3034 | PHA ; store register X in stack
3035 | TYA
3036 | PHA ; store register Y in stack
3037 |
3038 | LDA #%10000010 ; Limpia todas las banderas de interrupcion, incluyendo la de interrupcion de barrido
3039 | STA $FF09
3040 | LDA #%10100010 ; Enable raster interrupt signals from TED, and clear MSB in TED's raster register
3041 | STA $FF0A
3042 |
3043 | LDA $FB
3044 | PHA
3045 | LDA #$00
3046 | STA $FB
3047 | PHP
3048 | CLI
3049 | JSR $DB11 ; Scan keyboard
3050 | PLP
3051 | PLA
3052 | STA $FB
3053 |
3054 |
3055 | PLA
3056 | TAY ; restore register Y from stack
3057 | PLA
3058 | TAX ; restore register X from stack
3059 | PLA ; restore register A from stack
3060 | ;JMP $CE0E ; Jump into KERNAL's standard interrupt service routine to handle keyboard scan, cursor display etc.
3061 | JMP $FCBE
3062 |
3063 | ; --- Refresh modem init string
3064 | refresh_init:
3065 | +SetCursor $00,$06
3066 | ;Delete whole line
3067 | LDY #40
3068 | - LDA #$14
3069 | JSR CHROUT
3070 | DEY
3071 | BNE -
3072 | LDA #<(_sudtmp+5)
3073 | LDY #>(_sudtmp+5)
3074 | JSR printstring
3075 | ; +StringOut _sudtmp+5
3076 | RTS
3077 |
3078 | ; --- Edit modem init string
3079 | edit_init:
3080 | +EnROMs
3081 | LDA #$00
3082 | STA _sudtmp+5 ; Remove the previous string
3083 | JSR refresh_init ; Clear previous string on screen
3084 | LDA #>_filter
3085 | LDX #<_filter
3086 | LDY #38
3087 | JSR FILTERED_INPUT
3088 | LDY #$00 ; Copy new init string
3089 | - LDA fibuffer,Y
3090 | STA _sudtmp+5,Y
3091 | BEQ +
3092 | INY
3093 | CPY #38
3094 | BNE -
3095 | DEY
3096 | LDA #$00 ; safeguard for long/unterminated string
3097 | STA _sudtmp+5,Y
3098 | + JSR refresh_init ; Refresh init string on screen
3099 | SEI
3100 | ;+DisROMs
3101 | RTS
3102 |
3103 | ; --- cycle modem init baudrates
3104 | cycle_rates:
3105 | +EnROMs
3106 | +SetCursor $19,$07
3107 | LDX _sudtmp+4
3108 | INX
3109 | TXA
3110 | AND #$03
3111 | STA _sudtmp+4
3112 | TAY
3113 | _cr1:
3114 | LDA ($D8),Y
3115 | CLC
3116 | ADC #rates
3120 | TAY
3121 | TXA
3122 | JSR STROUT
3123 | SEI
3124 | ;+DisROMs
3125 | RTS
3126 |
3127 | ; --- display modem init baudrate
3128 | show_rate:
3129 | +SetCursor $19,$07
3130 | LDY _sudtmp+4
3131 | BPL _cr1
3132 |
3133 | ; --- Display phone book
3134 | phone_book:
3135 | +StringOut pbook0
3136 | +SetCursor $02,$02
3137 | LDA #<(_sudtmp+$2B)
3138 | LDY #>(_sudtmp+$2B)
3139 | JSR printstring
3140 | +SetCursor $02,$04
3141 | LDA #<(_sudtmp+$52)
3142 | LDY #>(_sudtmp+$52)
3143 | JSR printstring
3144 | +SetCursor $02,$06
3145 | LDA #<(_sudtmp+$79)
3146 | LDY #>(_sudtmp+$79)
3147 | JSR printstring
3148 | +SetCursor $02,$08
3149 | LDA #<(_sudtmp+$A0)
3150 | LDY #>(_sudtmp+$A0)
3151 | JSR printstring
3152 | +SetCursor $02,$0A
3153 | LDA #<(_sudtmp+$C7)
3154 | LDY #>(_sudtmp+$C7)
3155 | JSR printstring
3156 |
3157 | CLI
3158 | - JSR $EBDD ; Read keyboard buffer
3159 | BEQ -
3160 |
3161 | CMP #$5f ; <- back key
3162 | BNE +
3163 | JMP +++
3164 | + CMP #$31 ; 1
3165 | BCC - ; less ->
3166 | CMP #$36 ; 6
3167 | BCS - ; more or equal ->
3168 | PHA
3169 | +SetCursor $0D,$0D
3170 | PLA
3171 | PHA
3172 | JSR CHROUT
3173 | +StringOut pbook1
3174 |
3175 | PLA
3176 | SEC
3177 | SBC #$31 ; .A = preset-1
3178 | ASL
3179 | TAX
3180 | LDA pstable,X
3181 | STA .ph0+1
3182 | STA .ph1+1
3183 | LDA pstable+1,X
3184 | STA .ph0+2
3185 | STA .ph1+2
3186 |
3187 | -- JSR $EBDD ; Read keyboard buffer
3188 | BEQ --
3189 |
3190 | CMP #$5f ; <- back key
3191 | BNE +
3192 | JMP phone_book
3193 | + CMP #$45 ; Edit
3194 | BNE ++
3195 | LDA #>_filter
3196 | LDX #<_filter
3197 | LDY #38
3198 | JSR FILTERED_INPUT
3199 |
3200 | LDY #$00
3201 | - LDA fibuffer,Y
3202 | .ph0
3203 | STA _sudtmp+$2B,Y
3204 | BEQ +
3205 | INY
3206 | CPY #38
3207 | BNE -
3208 | DEY
3209 | LDA #$00 ; safeguard for long/unterminated string
3210 | BEQ .ph0
3211 | + JMP phone_book
3212 |
3213 | ++ CMP #$44 ; "Dial"
3214 | BNE --
3215 | LDA FLAGS1
3216 | AND #$02
3217 | BNE -- ; Only dial if terminal already started up
3218 |
3219 | LDY #$00
3220 | .ph1
3221 | LDA _sudtmp+$2B,Y
3222 | BEQ +
3223 | JSR SendID
3224 | INY
3225 | CPY #38
3226 | BNE .ph1
3227 | + LDA #$0D
3228 | JSR SendID
3229 | JMP dsexit
3230 |
3231 | ; !if _HARDTYPE_ = 56{
3232 | ; +DisKernal x
3233 | ; }
3234 |
3235 | +++
3236 | JSR data_bck
3237 | JMP _dosetup
3238 |
3239 | pstable:
3240 | !word _sudtmp+$2B,_sudtmp+$52,_sudtmp+$79,_sudtmp+$A0,_sudtmp+$C7
3241 |
3242 |
3243 | ; --- Copy setupdata to _sudtmp
3244 | bck_data:
3245 | SEI
3246 | +DisROMs
3247 | LDX #_sudend-setupdata+1;$EE
3248 | - LDA setupdata-1,X
3249 | STA _sudtmp-1,X
3250 | DEX
3251 | BNE -
3252 | +EnROMs
3253 | CLI
3254 | RTS
3255 |
3256 | ; --- Copy _sudtmp to setupdata
3257 | data_bck:
3258 | SEI
3259 | +DisROMs
3260 | LDX #_sudend-setupdata+1
3261 | - LDA _sudtmp-1,X
3262 | STA setupdata-1,X
3263 | DEX
3264 | BNE -
3265 | +EnROMs
3266 | CLI
3267 | RTS
3268 |
3269 | delfname: !text "S0:"
3270 | pfname: !text "RT.PREF"
3271 | pfname_n: !text ",S,W"
3272 | pfname_e:
3273 | _load_drive: !byte $FF
3274 |
3275 | ; Set/Reset setupdata from in-code values
3276 | res_prefs:
3277 | SEI
3278 | +DisROMs
3279 | _resp:
3280 | LDA rb1l+1 ; RTS Delay
3281 | STA setupdata
3282 | LDA rb1h+1
3283 | STA setupdata+1
3284 | LDA #$00
3285 | STA setupdata+2 ; ACIA base
3286 | STA setupdata+3 ; Screen enable
3287 | +EnROMs
3288 | CLI
3289 | RTS
3290 |
3291 | ; Set pref values from setupdata
3292 | set_prefs:
3293 | SEI
3294 | +DisROMs
3295 | LDA setupdata ; RTS delay
3296 | STA rb1l+1
3297 | LDA setupdata+1
3298 | STA rb1h+1
3299 | +EnROMs
3300 | CLI
3301 | RTS
3302 |
3303 | ;======================================================================
3304 | ; Adapted from codebase64, original by Schema
3305 | ; Input a string and store it in fibuffer, terminated with a null byte.
3306 | ; x:a is a pointer to the allowed list of characters, null-terminated.
3307 | ; max # of chars in y
3308 | ; returns num of chars entered in y.
3309 | ;======================================================================
3310 |
3311 | ; Example usage
3312 | ; FILTERED_TEXT
3313 | ; lda #>_filter
3314 | ; ldx #<_filter
3315 | ; ldy #38
3316 | ;Drop through
3317 |
3318 | ; Main entry
3319 | FILTERED_INPUT:
3320 | STY _fimax
3321 | STX .ficheck+1
3322 | STA .ficheck+2
3323 |
3324 | ;Zero characters received.
3325 | LDA #$00
3326 | STA _ficount
3327 | +StringOut _cursor+1 ; Print cursor
3328 |
3329 | ;Wait for a character.
3330 | .figet
3331 | JSR GETIN
3332 | BEQ .figet
3333 |
3334 | STA _filast
3335 |
3336 | CMP #$14 ;Delete
3337 | BEQ .fidel
3338 |
3339 | CMP #$0D ;Return
3340 | BEQ .fidone
3341 |
3342 | ;Check the allowed list of characters.
3343 | LDX #$00
3344 | .ficheck
3345 | LDA $FFFF,x ;Overwritten
3346 | BEQ .figet ;Reached end of list (0)
3347 |
3348 | CMP _filast
3349 | BEQ .fiok ;Match found
3350 |
3351 | ;Not end or match, keep checking
3352 | INX
3353 | BNE .ficheck
3354 |
3355 | .fiok
3356 | LDA _filast ;Get the char back
3357 | LDY _ficount
3358 | STA fibuffer,y ;Add it to string
3359 | STA _cursor
3360 | LDA #<_cursor
3361 | LDY #>_cursor
3362 | JSR printstring
3363 | ;JSR CHROUT ;Print it
3364 |
3365 | INC _ficount ;Next character
3366 |
3367 | ;End reached?
3368 | LDA _ficount
3369 | CMP _fimax
3370 | BEQ .fidone
3371 | ;Not yet.
3372 | BNE .figet
3373 |
3374 | .fidone
3375 | LDY _ficount
3376 | LDA #$00
3377 | STA fibuffer,y ;Zero-terminate
3378 | RTS
3379 |
3380 | ; Delete last character.
3381 | .fidel
3382 | ;First, check if we're at the beginning. If so, just exit.
3383 | LDA _ficount
3384 | BNE +
3385 | JMP .figet
3386 |
3387 | ;At least one character entered.
3388 | ;Move pointer back.
3389 | + DEC _ficount
3390 |
3391 | ;Store a zero over top of last character, just in case no other characters are entered.
3392 | LDY _ficount
3393 | LDA #$00
3394 | STA fibuffer,y
3395 |
3396 | ;Print the delete char
3397 | LDA #$14
3398 | STA _cursor
3399 | +StringOut _cursor
3400 | ; JSR CHROUT
3401 |
3402 | ;Wait for next char
3403 | JMP .figet
3404 |
3405 | ; Needed because BASIC Stringout doesn't play nice with quotes
3406 | printstring:
3407 | STA $6F
3408 | STY $70
3409 | LDY #$00
3410 | - LDA ($6F),Y
3411 | BEQ +
3412 | TAX
3413 | TYA
3414 | PHA
3415 | TXA
3416 | JSR CharOut
3417 | PLA
3418 | TAY
3419 | INY
3420 | BNE -
3421 | + RTS
3422 |
3423 |
3424 | _cursor
3425 | !byte $A6,$A6,$9D,$00 ; Hash, hash, crsr left, null
3426 | _filter
3427 | !text " ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890.,-+!?%&'()*:",$22,$00
3428 | _fimax
3429 | !byte $00
3430 |
3431 | _filast
3432 | !byte $00
3433 |
3434 | _ficount
3435 | !byte $00
3436 |
3437 | ; --- Open file
3438 | channel: !byte $00
3439 | fdrive: !byte $08
3440 |
3441 | ; A: Name length
3442 | ; X/Y: Name pointer
3443 | ; channel: Secondary address
3444 | ; fdrive: drive
3445 | ; File number same as channel, only one file open at a time anyways
3446 | fopen:
3447 | JSR SETNAM ; SETNAM
3448 | LDX fdrive
3449 | LDY channel
3450 | TYA ; file number
3451 | JSR SETLFS ; SETLFS
3452 | JMP KOPEN ; Open (Carry clear if ok)
3453 | ;RTS
3454 |
3455 | ; --- File close
3456 | fclose:
3457 | LDA channel ; file number
3458 | JSR KCLOSE ; CLOSE
3459 | JMP CLRCHN ; CLRCHN
3460 |
3461 | ; --- Read error channel
3462 | ; - CLOSE OTHER FILES BEFORE CALLING -
3463 | rechan:
3464 | LDA #errbuf
3467 | STA $9C
3468 | LDA #$0F
3469 | STA channel
3470 | LDA #$00
3471 | TAX
3472 | TAY
3473 | _rc1:
3474 | JSR fopen
3475 | BCS + ; error ->
3476 | LDX channel
3477 | JSR CHKIN ; CHKIN
3478 | LDA #$00
3479 | - JSR READST ; READST
3480 | BNE + ; EOF or read error ->
3481 | JSR CHRIN ; CHRIN
3482 | STA ($9B),Y
3483 | INC $9B
3484 | BNE -
3485 | INC $9C
3486 | BNE -
3487 | +
3488 | JMP fclose
3489 |
3490 | ; --- Save pref file
3491 | psave:
3492 | ; First update preferences data
3493 | JSR res_prefs
3494 | JSR set_prefs
3495 | ; then, try to delete existing file
3496 | LDA #errbuf
3499 | STA $9C
3500 | LDA #$0F
3501 | STA channel
3502 | LDA _load_drive
3503 | STA fdrive
3504 | LDA #pfname_n-delfname
3505 | LDX #delfname
3507 | JSR _rc1 ; Send command
3508 | ; Save data
3509 | LDA #$02
3510 | STA channel
3511 | LDA _load_drive
3512 | STA fdrive
3513 | LDA #pfname_e-pfname
3514 | LDX #pfname
3516 | JSR fopen
3517 | BCS .ser ; if carry set, an open error has ocurred
3518 | LDX channel
3519 | JSR CHKOUT ; CHKOUT
3520 | LDA #<_sudtmp
3521 | STA $9B
3522 | LDA #>_sudtmp
3523 | STA $9C
3524 | LDY #$00
3525 | - JSR READST ; READST
3526 | BNE .ser ; error ->
3527 | LDA ($9B),Y
3528 | JSR CHROUT ; CHROUT
3529 | INY
3530 | CPY #_sudend-setupdata ;45
3531 | BNE -
3532 | .ser
3533 | JSR fclose
3534 | RTS
3535 |
3536 |
3537 | ; --- Setup Texts
3538 | sut1:
3539 | ;Clear, Lower/upper, yellow
3540 | !text $93,$0E,$9E," --== rETROTERM sETUP SCREEN ==--"
3541 | !text $0D,$0D,"rts PULSE TIMING: ",$12,"+",$92," ",$12,"-"
3542 | !text $0D,$0D,"mODEM ",$12,"i",$92,"NIT STRING:",$0D,$0D,$0D
3543 | !text "iNITIAL MODEM BAUD ",$12,"r",$92,"ATE:"
3544 | !byte $00
3545 | sut2:
3546 | !text " "
3547 | !fill $05,$9D
3548 | !byte $00
3549 | sut3:
3550 | !text $12," p ",$92," pHONE BOOK",$0D,$0D
3551 | !text $12," f1 ",$92," tERMINAL ",$00
3552 | sut3_:
3553 | !text $12," f5 ",$92," sAVE SETTINGS",$00
3554 |
3555 | ; Phonebook screen
3556 | pbook0:
3557 | !text $93,$0E,$9E,$12," pHONE BOOK ",$92
3558 | !byte $60,$B2
3559 | !fill $26,$60
3560 | !text $12,"1",$92,$7D,$0D
3561 | !byte $1D,$7D,$0D
3562 | !text $12,"2",$92,$7D,$0D
3563 | !byte $1D,$7D,$0D
3564 | !text $12,"3",$92,$7D,$0D
3565 | !byte $1D,$7D,$0D
3566 | !text $12,"4",$92,$7D,$0D
3567 | !byte $1D,$7D,$0D
3568 | !text $12,"5",$92,$7D,$0D
3569 | !byte $1D,$7D,$0D
3570 | !byte $60,$B1
3571 | !fill $26,$60
3572 | !text $0D,"sELECT ENTRY:"
3573 | !fill $09,$11
3574 | !text $12," ",$5F," ",$92," back",$00
3575 |
3576 | pbook1:
3577 | !text $0D,$12,"e",$92,"DIT/",$12,"d",$92,"IAL",$0D,$00
3578 |
3579 | ; Baud rates
3580 | rates:
3581 | !text "skip",$00
3582 | !text " 300",$00
3583 | !text "1200",$00
3584 | !text "2400",$00
3585 | rate_offs:
3586 | !byte 0,5,10,15
3587 |
3588 | ; temporal setup data
3589 | _sudtmp:
3590 |
3591 |
3592 | fibuffer = _sudtmp+$EE ; String input buffer
3593 | errbuf = fibuffer
3594 |
3595 | suend
3596 | }
3597 | _suend
3598 |
3599 | load_drive: !byte $FF ; Drive to use for preferences file
3600 |
3601 | ; Setup data here
3602 | ; $00: RTS timing low
3603 | ; $01: RTS timing high
3604 | ; $02: ACIA base address high (even if not used)
3605 | ; $03: Flags:
3606 | ; bit 0: Screen enable during turbo transfers
3607 | ; $04: Early startup command baudrate:
3608 | ; 0: No early startup command
3609 | ; 1: 300 bauds
3610 | ; 2: 1200 bauds
3611 | ; 3: 2400 bauds
3612 | ; $05-$2A: Null terminated startup command (38 chars max). Pad with 0s
3613 | ; $2B-$51: Preset 1, null terminated, 0 padded
3614 | ; $52-$78: Preset 2...
3615 | ; $79-$9F: Preset 3...
3616 | ; $A0-$C6: Preset 4...
3617 | ; $C7-$ED: Preset 5...
3618 | setupdata:
3619 | !byte $1C,$00,$DE,$00,$02
3620 | !text "ATF0B19200",$00
3621 | _sudf
3622 | !fill 43-(_sudf-setupdata),$00
3623 | _preset1
3624 | !text "ATD LU4FBU.DDNS.NET:6400",00
3625 | _p1f
3626 | !fill 39-(_p1f-_preset1),$00
3627 | _preset2
3628 | !text "ATDSOTANOMSXBBS.ORG:6400",00
3629 | _p2f
3630 | !fill 39-(_p2f-_preset2),$00
3631 | _preset3
3632 | !text "",00
3633 | _p3f
3634 | !fill 39-(_p3f-_preset3),$00
3635 | _preset4
3636 | !text "",00
3637 | _p4f
3638 | !fill 39-(_p4f-_preset4),$00
3639 | _preset5
3640 | !text "",00
3641 | _p5f
3642 | !fill 39-(_p5f-_preset5),$00
3643 | _sudend
3644 |
3645 | ; CmdA4 subsystems offsets
3646 |
3647 | A4offsets:
3648 | !byte _sub0-A4array,_sub1-A4array,_sub2-A4array,_sub3-A4array
3649 | !byte _sub4-A4array,_sub5-A4array,_sub6-A4array,_subnull-A4array
3650 |
3651 | ; CmdA4 subsystems response array
3652 | A4array:
3653 | _sub0
3654 | !byte $01,$01 ; $00: Platform/Refresh rate
3655 | _sub1
3656 | !byte $02,$28,$19 ; $01: Text screen dimensions
3657 | _sub2
3658 | !byte $02 ; $02: Connection speed
3659 | !byte $08
3660 | _sub3
3661 | !byte $02 ; $03: RAM size
3662 | !word $0040
3663 | _sub4
3664 | !byte $02
3665 | !word $0000 ; $04: VRAM size
3666 | _sub5
3667 | !byte $01,$00 ; $05: Graphic modes
3668 | _sub6
3669 | !byte $02,$00,%00001001 ; $06: Audio
3670 | _subnull
3671 | !byte $00 ; Entry not implemented
3672 |
3673 | ENDSHADOW
3674 | }
3675 | _ENDSHADOW_
3676 |
3677 | ;/////////////////////////
3678 | ; Early setup code
3679 | ;/////////////////////////
3680 | ; Executed before starting up retroterm
3681 | ; Try to load setup file, if none if found, show setup screen
3682 | ; if setup file is found, setup and start retroterm
3683 | earlysetup:
3684 | SEI
3685 | +DisROMs
3686 | LDA #$02 ; Set startup flag bit
3687 | STA FLAGS1
3688 | ; Copy routines to lower RAM ($0B00)
3689 | LDX #$01
3690 | - LDA _sudata,X
3691 | STA SOURCEPTR,X
3692 | LDA _sudata+2,X
3693 | STA DESTPTR,X
3694 | LDA _sudata+4,X
3695 | STA CSIZE,X
3696 | DEX
3697 | BPL -
3698 | JSR _MemCpy ;Do mem copy
3699 | JSR res_prefs ; Reset preferences
3700 | JSR bck_data ; And init _sudtmp
3701 | +DisROMs
3702 | LDA load_drive ; Check last used device
3703 | CMP #$08
3704 | BCS ++
3705 | ; retroterm was not loaded from disk
3706 | ; use first detected device
3707 | LDX #$00
3708 | - CPX #$08
3709 | BNE +
3710 | ; +EnKernal a
3711 | ; JSR res_prefs ; Reset preferences
3712 | ; JSR bck_data
3713 | BEQ .esq ; No available drive found > show setup
3714 | + LDA DRIVES,X
3715 | BPL + ; Available drive
3716 | INX
3717 | BNE -
3718 | + TXA
3719 | ++ STA load_drive
3720 | STA _load_drive
3721 | +EnROMs
3722 | ; CLI
3723 | ; JSR res_prefs ; Reset preferences
3724 | ; JSR bck_data ; And init _sudtmp
3725 | JSR loadsetup ; Get preferences from disk, if any
3726 | BCC + ; prefs ok run retroterm
3727 | .esq
3728 | ; LDA #$00
3729 | JSR dosetup ; prefs error, run setup, alternative entry point
3730 | + +EnROMs
3731 | LDA _sudtmp+4
3732 | BEQ + ; Skip init string
3733 | JSR _init_modem
3734 | + RTS
3735 |
3736 | ; --- Load setup file
3737 | loadsetup:
3738 | LDA #$02
3739 | STA channel
3740 | LDA _load_drive
3741 | STA fdrive
3742 | LDA #pfname_n-pfname
3743 | LDX #pfname
3745 | JSR fopen
3746 | BCS .oerr ; if carry set, an open error has happened
3747 | LDX channel ; filenumber 2
3748 | JSR CHKIN ; call CHKIN (file 2 now used as input)
3749 |
3750 | LDA #<_sudtmp
3751 | STA $9B
3752 | LDA #>_sudtmp
3753 | STA $9C
3754 |
3755 | LDY #$00
3756 |
3757 | - JSR READST ; call READST (read status byte)
3758 | BNE .eof ; either EOF or read error
3759 | JSR CHRIN ; call CHRIN (get a byte from file)
3760 | STA ($9B),Y ; write byte to memory
3761 | INC $9B
3762 | BNE -
3763 | INC $9C
3764 | JMP - ; next byte
3765 |
3766 | .eof
3767 | CMP #$40 ; end of file?
3768 | BNE .oerr
3769 | JSR fclose ; close file
3770 | ; Copy setup preferences
3771 | SEI
3772 | +DisROMs
3773 | LDX #$EF
3774 | - LDA _sudtmp-1,X
3775 | STA setupdata-1,X
3776 | DEX
3777 | BNE -
3778 | +EnROMs
3779 | CLI
3780 | CLC ; Prefs loaded ok
3781 | RTS
3782 |
3783 | ; handle open or read errors
3784 | .oerr
3785 | LDA $90 ; STatus
3786 | BMI ++ ; Device not present?
3787 | JSR fclose
3788 | JSR rechan
3789 | ++ SEC ; Prefs load error
3790 | RTS
3791 |
3792 | ; Send init string
3793 | _init_modem:
3794 | LDA #%00001011 ; no parity, no echo, no tx irq (rts=0, receive enable), no rx irq, rx enabled (dtr=0)
3795 | STA ACIACOMMAND
3796 | LDX _sudtmp+4 ; get baud rate
3797 | DEX
3798 | LDA _bauds,x
3799 | STA ACIACONTROL
3800 | LDX #$00
3801 | - LDA _sudtmp+5,x
3802 | BEQ +
3803 | JSR SendID
3804 | INX
3805 | CPX #38
3806 | BNE -
3807 | + LDA #$0D
3808 | JSR SendID
3809 | RTS
3810 |
3811 | _bauds:
3812 | !byte %00010110, %00011000, %00011010
3813 |
--------------------------------------------------------------------------------