Skip to content

Commit 04ccdad

Browse files
committed
Library updated to version 1.0 with 3 new functions added
1 parent ba09407 commit 04ccdad

11 files changed

Lines changed: 172 additions & 19 deletions

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ ZP registers affected: none<br>
157157

158158
## Function name: get_bank
159159
Purpose: Get the current VERA bank<br>
160-
Call address: `VTUILIB+53`<br>
160+
Call address: `VTUILIB+56`<br>
161161
Macro name: `VTUI_GET_BANK`<br>
162162
Routine name: `vtui_get_bank`<br>
163163
Communication registers: .C<br>
@@ -189,7 +189,7 @@ ZP registers affected: r0l ($02)<br>
189189

190190
## Function name: get_stride
191191
Purpose: Get the current VERA stride value<br>
192-
Call address: `VTUILIB+56`<br>
192+
Call address: `VTUILIB+59`<br>
193193
Macro name: `VTUI_GET_STRIDE`<br>
194194
Routine name: `vtui_get_stride`<br>
195195
Communication registers: .A<br>
@@ -221,7 +221,7 @@ ZP registers affected: none<br>
221221

222222
## Function name: get_decr
223223
Purpose: Get the current VERA decrement bit<br>
224-
Call address: `VTUILIB+59`<br>
224+
Call address: `VTUILIB+62`<br>
225225
Macro name: `VTUI_GET_DECR`<br>
226226
Routine name: `vtui_set_decr`<br>
227227
Communication registers: .C<br>

VTUI1.0.BIN

971 Bytes
Binary file not shown.

build.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/bash
2-
rm -rf *.o *.PRG VTUI0.9.BIN
3-
acme -f cbm -o VTUI0.9.BIN -l vtuilib-generic.lst vtuilib-generic.asm
2+
rm -rf *.o *.PRG *.BIN
3+
acme -f cbm -o VTUI1.0.BIN -l vtuilib-generic.lst vtuilib-generic.asm
44
acme -f cbm -o EXAMPL01.PRG example01.asm
55
acme -f cbm -o EXAMPL02.PRG example02.asm
66
acme -f cbm -o ACME-EX1.PRG acme-ex01.asm

cc65-ex01.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,24 @@ int main() {
66
// Load VTUI library into pre-allocated memory and initialize it
77
// ensure defined memory is large enough to hold VTUI library
88
// char vtui[1023];
9-
// vtui_load(vtui, "vtui0.9.bin");
9+
// vtui_load(vtui, "vtui1.0.bin");
1010
// vtui_initialize(vtui);
1111

1212
// Load VTUI library to address 0x0400 and initialize it
13-
vtui_load((char*)0x0400, "vtui0.9.bin");
13+
vtui_load((char*)0x0400, "vtui1.0.bin");
1414
vtui_initialize((char*)0x0400);
1515

1616
// Switch to standard PETSCII character set
1717
__asm__ ("lda #$8E");
1818
__asm__ ("jsr $FFD2");
1919

2020
if (vtui_screen_set(SCRMODE40X30)) {
21-
vtui_set_stride(1);
22-
vtui_set_decr(0);
21+
if (vtui_get_bank()!=1)
22+
vtui_set_bank(1);
23+
if (vtui_get_stride()!=1)
24+
vtui_set_stride(1);
25+
if (vtui_get_decr()!=0)
26+
vtui_set_decr(0);
2327
vtui_clr_scr(vtui_pet2scr(' '), (LIGHTGRAY<<4)+BLACK);
2428

2529
vtui_gotoxy(11, 2);
@@ -45,7 +49,7 @@ int main() {
4549
// Write a character to show header starts
4650
vtui_plot_char(0x73, 0x74);
4751
// Write box header
48-
vtui_print_str("version 0.9", 11, (YELLOW<<4)+PURPLE, PETSCII_TRUE);
52+
vtui_print_str("version 1.0", 11, (YELLOW<<4)+PURPLE, PETSCII_TRUE);
4953
// Write a character to show header ends
5054
vtui_plot_char(0x6B, 0x74);
5155
vtui_gotoxy(3, 17);

example01.asm

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ VTUI_border = LIBSTART+44
4343
VTUI_save_rect = LIBSTART+47
4444
VTUI_rest_rect = LIBSTART+50
4545
VTUI_input_str = LIBSTART+53
46+
VTUI_get_bank = LIBSTART+56
47+
vtui_get_stride = LIBSTART+59
48+
vtui_get_decr = LIBSTART+62
4649

4750
main:
4851
; Load the library using standard Kernal functions
@@ -274,13 +277,13 @@ load_library:
274277
rts
275278

276279
Libname !text "VTUI LIBRARY"
277-
Verstr !text "VERSION 0.9"
280+
Verstr !text "VERSION 1.0"
278281
Boxstr !text "BOXES WITH OR WITHOUT BORDERS"
279282
Hlinestr !text "HORIZONTAL LINES"
280283
Vlinestr !text "VERTICAL LINES"
281284
Plotstr !text "PLOT OR SCAN CHARACTERS"
282285
Dramstr !text "DIRECTLY TO/FROM SCREEN RAM"
283-
Morestr !text "***MORE TO SEE AND TO COME***"
286+
Morestr !text "*** NOW WITH CC65 SUPPORT ***"
284287

285-
Fname !text "VTUI0.9.BIN"
288+
Fname !text "VTUI1.0.BIN"
286289
End_fname

example02.asm

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,11 @@ VTUI_scr2pet = LIBSTART+41
4343
VTUI_border = LIBSTART+44
4444
VTUI_save_rect = LIBSTART+47
4545
VTUI_rest_rect = LIBSTART+50
46+
VTUI_input_str = LIBSTART+53
47+
VTUI_get_bank = LIBSTART+56
48+
vtui_get_stride = LIBSTART+59
49+
vtui_get_decr = LIBSTART+62
50+
4651

4752
main:
4853
; Initialize the library
@@ -250,12 +255,12 @@ main:
250255
rts
251256

252257
Libname !text "VTUI LIBRARY"
253-
Verstr !text "VERSION 0.9"
258+
Verstr !text "VERSION 1.0"
254259
Boxstr !text "BOXES WITH OR WITHOUT BORDERS"
255260
Hlinestr !text "HORIZONTAL LINES"
256261
Vlinestr !text "VERTICAL LINES"
257262
Plotstr !text "PLOT OR SCAN CHARACTERS"
258263
Dramstr !text "DIRECTLY TO/FROM SCREEN RAM"
259-
Morestr !text "***MORE TO SEE AND TO COME***"
264+
Morestr !text "*** NOW WITH CC65 SUPPORT ***"
260265

261-
VTUI !bin "VTUI0.9.BIN"
266+
VTUI !bin "VTUI1.0.BIN"

vtuilib-acme.inc

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,9 @@ vtui_border = VTUI_LIB+44
8787
vtui_save_rect = VTUI_LIB+47
8888
vtui_rest_rect = VTUI_LIB+50
8989
vtui_input_str = VTUI_LIB+53
90+
vtui_get_bank = VTUI_LIB+56
91+
vtui_get_stride = VTUI_LIB+59
92+
vtui_get_decr = VTUI_LIB+62
9093

9194
jsr vtui_initialize
9295
jmp VTUI_LIB_END
@@ -112,6 +115,16 @@ vtui_input_str = VTUI_LIB+53
112115
jsr vtui_set_bank
113116
}
114117

118+
; *****************************************************************************
119+
; Get current VERA bank (high memory bit)
120+
; *****************************************************************************
121+
; USES: .A
122+
; RETURNS: .C = Bank number, 0 or 1
123+
; *****************************************************************************
124+
!macro VTUI_GET_BANK {
125+
jsr vtui_get_bank
126+
}
127+
115128
; *****************************************************************************
116129
; Set the stride without changing other values in VERA_ADDR_H
117130
; *****************************************************************************
@@ -122,6 +135,15 @@ vtui_input_str = VTUI_LIB+53
122135
jsr vtui_set_stride
123136
}
124137

138+
; *****************************************************************************
139+
; Get current VERA stride value
140+
; *****************************************************************************
141+
; RETURNS: .A = stride value
142+
; *****************************************************************************
143+
!macro VTUI_GET_STRIDE {
144+
jsr vtui_get_stride
145+
}
146+
125147
; *****************************************************************************
126148
; Set the decrement value without changing other values in VERA_ADDR_H
127149
; *****************************************************************************
@@ -132,6 +154,16 @@ vtui_input_str = VTUI_LIB+53
132154
jsr vtui_set_decr
133155
}
134156

157+
; *****************************************************************************
158+
; Get the current VERA decrement value
159+
; *****************************************************************************
160+
; USES: .A
161+
; RETURNS: .C (1 = decrement, 0 = increment)
162+
; *****************************************************************************
163+
!macro VTUI_GET_DECR {
164+
jsr vtui_get_decr
165+
}
166+
135167
; *****************************************************************************
136168
; Write character and possibly color to current VERA address
137169
; If VERA stride = 1 and decrement = 0, colorcode in X will be written as well.
@@ -300,6 +332,6 @@ vtui_input_str = VTUI_LIB+53
300332
jsr vtui_input_str
301333
}
302334

303-
VTUI: !bin "VTUI0.9.BIN"
335+
VTUI: !bin "VTUI1.0.BIN"
304336

305337
VTUI_LIB_END:

vtuilib-ca65.inc

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,9 @@ vtui_border = VTUI_LIB+44
8787
vtui_save_rect = VTUI_LIB+47
8888
vtui_rest_rect = VTUI_LIB+50
8989
vtui_input_scr = VTUI_LIB+53
90+
vtui_get_bank = VTUI_LIB+56
91+
vtui_get_stride = VTUI_LIB+59
92+
vtui_get_decr = VTUI_LIB+62
9093

9194
jsr vtui_initialize
9295
jmp VTUI_LIB_END
@@ -112,6 +115,16 @@ vtui_input_scr = VTUI_LIB+53
112115
jsr vtui_set_bank
113116
.endmacro
114117

118+
; *****************************************************************************
119+
; Get current VERA bank (high memory bit)
120+
; *****************************************************************************
121+
; USES: .A
122+
; RETURNS: .C = Bank number, 0 or 1
123+
; *****************************************************************************
124+
.macro VTUI_GET_BANK
125+
jsr vtui_get_bank
126+
.endmacro
127+
115128
; *****************************************************************************
116129
; Set the stride without changing other values in VERA_ADDR_H
117130
; *****************************************************************************
@@ -122,6 +135,15 @@ vtui_input_scr = VTUI_LIB+53
122135
jsr vtui_set_stride
123136
.endmacro
124137

138+
; *****************************************************************************
139+
; Get current VERA stride value
140+
; *****************************************************************************
141+
; RETURNS: .A = stride value
142+
; *****************************************************************************
143+
.macro VTUI_GET_STRIDE
144+
jsr vtui_get_stride
145+
.endmacro
146+
125147
; *****************************************************************************
126148
; Set the decrement value without changing other values in VERA_ADDR_H
127149
; *****************************************************************************
@@ -132,6 +154,16 @@ vtui_input_scr = VTUI_LIB+53
132154
jsr vtui_set_decr
133155
.endmacro
134156

157+
; *****************************************************************************
158+
; Get the current VERA decrement value
159+
; *****************************************************************************
160+
; USES: .A
161+
; RETURNS: .C (1 = decrement, 0 = increment)
162+
; *****************************************************************************
163+
.macro VTUI_GET_DECR
164+
jsr vtui_get_decr
165+
.endmacro
166+
135167
; *****************************************************************************
136168
; Write character and possibly color to current VERA address
137169
; If VERA stride = 1 and decrement = 0, colorcode in X will be written as well.
@@ -300,6 +332,6 @@ vtui_input_scr = VTUI_LIB+53
300332
jsr vtui_input_str
301333
.endmacro
302334

303-
VTUI: .incbin "VTUI0.9.BIN"
335+
VTUI: .incbin "VTUI1.0.BIN"
304336

305337
VTUI_LIB_END:

vtuilib-cc65.asm

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,11 @@
66
.export _vtui_initialize
77
.export _vtui_screen_set
88
.export _vtui_set_bank
9+
.export _vtui_get_bank
910
.export _vtui_set_stride
11+
.export _vtui_get_stride
1012
.export _vtui_set_decr
13+
.export _vtui_get_decr
1114
.export _vtui_clr_scr
1215
.export _vtui_gotoxy
1316
.export _vtui_plot_char
@@ -120,7 +123,7 @@ _vtui_initialize:
120123
: iny ; Add 3 to .Y indexing
121124
iny
122125
iny
123-
cpy #57 ; Ensure we have gone through all addresses
126+
cpy #66 ; Ensure we have gone through all addresses
124127
bne :-- ; below
125128

126129
; Library is designed to work with standard PETSCII character set, but
@@ -148,19 +151,46 @@ _vtui_set_bank:
148151
ror
149152
jmp vtui_set_bank
150153

154+
; *****************************************************************************
155+
; Return current bank number
156+
; *****************************************************************************
157+
_vtui_get_bank:
158+
ldx #0
159+
jsr vtui_get_bank
160+
lda #0
161+
rol
162+
rts
163+
151164
; *****************************************************************************
152165
; Set VERA stride, value passed as argument and available in A
153166
; *****************************************************************************
154167
_vtui_set_stride:
155168
jmp vtui_set_stride
156169

170+
; *****************************************************************************
171+
; Return current stride value
172+
; *****************************************************************************
173+
_vtui_get_stride:
174+
ldx #0
175+
jmp vtui_get_stride
176+
157177
; *****************************************************************************
158178
; Move inc/dec value into .C and call vtui_set_decr
159179
; *****************************************************************************
160180
_vtui_set_decr:
161181
ror
162182
jmp vtui_set_decr
163183

184+
; *****************************************************************************
185+
; Return current decrement value
186+
; *****************************************************************************
187+
_vtui_get_decr:.byte $db
188+
ldx #0
189+
jsr vtui_get_decr
190+
lda #0
191+
rol
192+
rts
193+
164194
; *****************************************************************************
165195
; Get char and color arguments into registers and call vtui_clr_scr
166196
; *****************************************************************************
@@ -371,3 +401,9 @@ vtui_rest_rect:
371401
jmp $0000
372402
vtui_input_str:
373403
jmp $0000
404+
vtui_get_bank:
405+
jmp $0000
406+
vtui_get_stride:
407+
jmp $0000
408+
vtui_get_decr:
409+
jmp $0000

vtuilib-cc65.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,14 @@ extern void __fastcall__ vtui_initialize(char *addr);
4545
extern char __fastcall__ vtui_screen_set(char mode);
4646
// Set high bit (bank) of VERA address without touching anything else in VERA_ADDR_H
4747
extern void __fastcall__ vtui_set_bank(char bank);
48+
extern char __fastcall__ vtui_get_bank();
4849
// Set stride value without touching anything else in VERA_ADDR_H
4950
extern void __fastcall__ vtui_set_stride(char stride);
51+
extern char __fastcall__ vtui_get_stride();
5052
// Set Decrement bit in VERA_ADDR_H without touching anything else, use the defined
5153
// VTUI_INC and VTUI_DEC constants for clarity
5254
extern void __fastcall__ vtui_set_decr(char decr);
55+
extern char __fastcall__ vtui_get_decr();
5356
// Fill screen with "fillchar" characters and set their color to "color"
5457
extern void __fastcall__ vtui_clr_scr(char fillchar, char color);
5558
// Set VERA address registers to point to X,Y coordinates (max 79,59). Assumes bank=1

0 commit comments

Comments
 (0)