Skip to content

Commit 19410d7

Browse files
committed
Added DEFINE VRAM READ. New examples brinquitos.bas and vramcopy.bas
1 parent cf7c739 commit 19410d7

9 files changed

Lines changed: 565 additions & 66 deletions

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ The following files compose the compiler:
5050
README.md This file
5151

5252
examples/bank.bas Bank-switching example.
53+
examples/brinquitos.bas Jumping game.
54+
examples/controller.bas Controller test.
5355
examples/demo.bas Demo of graphics.
5456
examples/face_joystick.bas Moving face with joystick.
5557
examples/happy_face.bas Bouncing face.
@@ -60,8 +62,10 @@ The following files compose the compiler:
6062
examples/space_attack.bas Game example.
6163
examples/test1.bas Moving stars.
6264
examples/test2.bas Arithmetic test.
65+
examples/varptr.bas VARPTR example for redefining graphics.
6366
examples/vgm.bas VGM audio player.
6467
examples/viboritas.bas Game example.
68+
examples/vramcopy.bas VRAM copy example.
6569

6670

6771
### Usage guide

cvbasic.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3265,6 +3265,7 @@ void compile_statement(int check_for_else)
32653265
}
32663266
} else if (strcmp(name, "DEFINE") == 0) {
32673267
int pletter = 0;
3268+
int vram_read = 0;
32683269

32693270
get_lex();
32703271
if (lex != C_NAME) {
@@ -3502,6 +3503,9 @@ void compile_statement(int check_for_else)
35023503
if (lex == C_NAME && strcmp(name, "PLETTER") == 0) {
35033504
pletter = 1;
35043505
get_lex();
3506+
} else if (lex == C_NAME && strcmp(name, "READ") == 0) {
3507+
vram_read = 1;
3508+
get_lex();
35053509
}
35063510
target2 = evaluate_save_expression(1, TYPE_16);
35073511
if (lex == C_COMMA)
@@ -3636,7 +3640,11 @@ void compile_statement(int check_for_else)
36363640
} else {
36373641
cpuz80_1op("CALL", "nmi_off");
36383642
}
3639-
generic_call("LDIRVM");
3643+
if (vram_read) {
3644+
generic_call("LDIRMV");
3645+
} else {
3646+
generic_call("LDIRVM");
3647+
}
36403648
if (target == CPU_6502)
36413649
cpu6502_noop("CLI");
36423650
else if (target == CPU_9900)

cvbasic_6502_prologue.asm

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
; Revision date: Aug/21/2024. Added support for keypad.
1313
; Revision date: Aug/30/2024. Changed mode bit to bit 3 (avoids collision
1414
; with flicker flag).
15+
; Revision date: Oct/15/2024. Added LDIRMV.
1516
;
1617

1718
CPU 6502
@@ -158,6 +159,28 @@ FILVRM:
158159
BNE .1 ; 2/3/4
159160
RTS
160161

162+
LDIRMV:
163+
LDA temp
164+
LDY temp+1
165+
JSR SETRD
166+
LDA temp2
167+
BEQ .1
168+
INC temp2+1
169+
.1:
170+
LDY #0
171+
.2:
172+
LDA $3000 ; 4
173+
STA (pointer),Y ; 5/6
174+
INC pointer ; 5
175+
BNE .3 ; 2/3/4
176+
INC pointer+1 ; 5
177+
.3:
178+
DEC temp2 ; 5
179+
BNE .2 ; 2/3/4
180+
DEC temp2+1 ; 5
181+
BNE .2 ; 2/3/4
182+
RTS
183+
161184
LDIRVM:
162185
LDA pointer
163186
LDY pointer+1

cvbasic_9900_prologue.asm

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
; Revision date Aug/16/2024. Corrected bug in define_char_unpack.
1818
; Revision date Aug/18/2024. Ported bugfixes to TMS9900 version
1919
; Revision date Aug/30/2024. All samples except pletter and banking working on TMS9900 version
20+
; Revision date Oct/15/2024. Added LDIRMV.
2021

2122
;
2223
; Platforms supported:
@@ -252,6 +253,21 @@ FILVRM
252253
jne -!1
253254
b *r11
254255

256+
; Read VRAM - address in R0, CPU data at R2, count in R3
257+
; Inline address set to avoid needing to cache r11
258+
LDIRMV
259+
swpb r2
260+
movb r2,@VDPWADR
261+
swpb r2
262+
movb r2,@VDPWADR
263+
swpb r2
264+
swpb r2
265+
!1
266+
movb @VDPDATA,*r0+
267+
dec r3
268+
jne -!1
269+
b *r11
270+
255271
; Load VRAM - address in R0, CPU data at R2, count in R3
256272
; Original: address in pointer, CPU address at temp, count in temp2
257273
; Inline address set to avoid needing to cache r11

cvbasic_prologue.asm

Lines changed: 58 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@
3636
; and Casio PV-2000.
3737
; Revision date: Aug/30/2024. Changed mode bit to bit 3 (avoids collision
3838
; with flicker flag).
39+
; Revision date: Oct/15/2024. Added LDIRMV. Solved bug where asterisk and number
40+
; keys values were inverted.
3941
;
4042

4143
JOYSEL: equ $c0
@@ -286,6 +288,21 @@ FILVRM:
286288
; 37 42
287289
ret
288290

291+
LDIRMV:
292+
ex de,hl
293+
call SETRD
294+
ex (sp),hl
295+
ex (sp),hl
296+
.1:
297+
ld a,(VDP)
298+
ld (de),a
299+
inc de
300+
dec bc
301+
ld a,b
302+
or c
303+
jp nz,.1
304+
ret
305+
289306
LDIRVM:
290307
EX DE,HL
291308
CALL SETWRT
@@ -366,29 +383,51 @@ FILVRM:
366383
; 35 40
367384
ret
368385

386+
LDIRMV:
387+
ex de,hl
388+
call SETRD
389+
ex (sp),hl
390+
ex (sp),hl
391+
.1:
392+
in a,(VDP)
393+
ld (de),a
394+
if SORD
395+
nop
396+
endif
397+
if SG1000+MEMOTECH+EINSTEIN
398+
nop ; SG1000 is 3.58 mhz, but SC3000 is 4 mhz.
399+
nop
400+
endif
401+
inc de
402+
dec bc
403+
ld a,b
404+
or c
405+
jp nz,.1
406+
ret
407+
369408
LDIRVM:
370-
EX DE,HL
371-
CALL SETWRT
372-
EX DE,HL
373-
DEC BC
374-
INC C
375-
LD A,B
376-
LD B,C
377-
INC A
378-
LD C,VDP
409+
ex de,hl
410+
call SETWRT
411+
ex de,hl
412+
dec bc
413+
inc c
414+
ld a,b
415+
ld b,c
416+
inc a
417+
ld c,VDP
379418
.1:
380419
if SORD
381-
NOP
420+
nop
382421
endif
383422
if SG1000+MEMOTECH+EINSTEIN
384-
NOP ; SG1000 is 3.58 mhz, but SC3000 is 4 mhz.
385-
NOP
423+
nop ; SG1000 is 3.58 mhz, but SC3000 is 4 mhz.
424+
nop
386425
endif
387-
OUTI
388-
JP NZ,.1
389-
DEC A
390-
JP NZ,.1
391-
RET
426+
outi
427+
jp nz,.1
428+
dec a
429+
jp nz,.1
430+
ret
392431
endif
393432

394433
LDIRVM3:
@@ -478,8 +517,8 @@ nmi_on:
478517

479518
if COLECO
480519
keypad_table:
481-
db $0f,$08,$04,$05,$0c,$07,$0a,$02
482-
db $0d,$0b,$00,$09,$03,$01,$06,$0f
520+
db $0f,$08,$04,$05,$0c,$07,$0b,$02
521+
db $0d,$0a,$00,$09,$03,$01,$06,$0f
483522
endif
484523

485524
cls:

0 commit comments

Comments
 (0)