Progress has been made with the CC65 journey.
I managed to at least get my ball bouncer test program into the 6502 Program Memory using the CC65 toolset.
The program code was placed in an endless loop in the .SEGMENT "STARTUP" just to make sure my Binary was correct.
At this point, I do not have any C code written, and I know the journey has only just begun.
Here is what I have done so far....
1) Deleted everything but the CC65 executable files. Don't need any of the other stuff!!2) Made a batch file based on help from the example posted by Michael...Code:
cc65 -t none --cpu 65C02 Main.c
ca65 --cpu 65C02 Main.s
ca65 --cpu 65C02 Vulcan-74.s
ld65 -C Vulcan-74.cfg Vulcan-74.o Main.o -o Cartridge.bin
pause
exit
3) Made a memory configuration file using help from the AtariAge forum posts...Code:
MEMORY {
ZP: start = 00000, size = 00256, type = rw;
IO: start = 00512, size = 00256, fill = yes, fillval=234, file = %O;
RAM: start = 00768, size = 64764, fill = yes, fillval=234, file = %O;
VECTORS: start = 65532, size = 00004, fill = yes, fillval=234, file = %O;
}
SEGMENTS {
ZEROPAGE: load = ZP, type = zp;
STARTUP: load = RAM, type = ro;
CODE: load = RAM, type = ro;
VECTORS: load = VECTORS, type = ro;
}
4) Started a Vulcan-74 Library based on some coding I did in the Kowalski Assembler...Code:
; ********************************************************************************
; *** VULCAN-74 STARTUP SEQUENCE
; ********************************************************************************
; RESET VECTOR VALUE 00768 STORED AT ADDRESS 65532
.SEGMENT "VECTORS"
.BYTE <00768
.BYTE >00768
; PROGRAM CODE BEGINS AT ADDRESS 00768
.EXPORT __STARTUP__ : absolute = 1;
.SEGMENT "STARTUP"
; SET GPU MEMORY SELECT TO DISABLED = 0
STZ 549
; temp set alpha $$$ make sub
STZ 535
; CLEAR DECIMAL MODE
CLD
; SIMPLE BALL BOUNCE TEST BELOW WILL BE REPLACED BY STARTUP CODE
; DEFINE BALL VARS
ballx = 100
STZ ballx
STZ ballx+1
balldx = 102
STZ balldx
ballvx = 103
LDA #3
STA ballvx
bally = 104
STZ bally
STZ bally+1
balldy = 106
STZ balldy
ballvy = 107
LDA #3
STA ballvy
; LOAD AND PLOT 1024 PIXELS (32x32)
LDX #0
LDY #0
SPR_LOOP:
; LOAD PIXEL FROM PROGRAM MEMORY
LDA BALLS,X
; PLOT PIXEL TO SPRITE MEMORY
STX 0 ; DEST ADDRESS.LO
STY 1 ; DEST ADDRESS.MD
STZ 2 ; DEST ADDRESS.HI
STA 3 ; PIXEL DATA
JSR SPRITE_PLOT
; COMPLETE LOOP
INX
BNE SPR_LOOP
INC SPR_LOOP+2
INY
CPY #32
BNE SPR_LOOP
; ********************************************************************************
; *** MAIN PROGRAM LOOP
; ********************************************************************************
MAIN:
; MOVE SPRITE RIGHT
LDA #0
CMP balldx
BNE SHR
CLC
LDA ballx
ADC ballvx
STA ballx
BCC MSR
INC ballx+1
MSR:
; SPRITE HIT WALL RIGHT
LDA #1
CMP ballx+1
BNE SHR
LDA #112
CMP ballx
BCS SHR
LDA #1
STA balldx
SHR:
; MOVE SPRITE LEFT
lda #1
CMP balldx
BNE SHL
SEC
LDA ballx
SBC ballvx
STA ballx
BCS MSL
DEC ballx+1
MSL:
; SPRITE HIT WALL LEFT
LDA #0
CMP ballx+1
BNE SHL
CMP ballx
BCC SHL
STZ balldx
SHL:
; BOUNCE SIMULATION
LDA bally
LSR
LSR
LSR
INA
sta ballvy
; MOVE SPRITE DOWN
LDA #0
CMP balldy
BNE SHD
CLC
LDA bally
ADC ballvy
STA bally
BCC MSD
INC bally+1
MSD:
; SPRITE HIT WALL DOWN
LDA #1
CMP bally+1
BNE SHD
LDA #12
CMP bally
BCS SHD
LDA #1
STA balldy
SHD:
; MOVE SPRITE UP
lda #1
CMP balldy
BNE SHU
SEC
LDA bally
SBC ballvy
STA bally
BCS MSU
DEC bally+1
MSU:
; SPRITE HIT WALL UP
LDA #0
CMP bally+1
BNE SHU
CMP bally
BCC SHU
STZ balldy
SHU:
; sprite pos
LDA ballx
STA 0
LDA ballx+1
STA 1
LDA bally
STA 2
LDA bally+1
STA 3
; sprite size
LDA #32
STA 4
STA 6
LDA #0
STA 5
STA 7
; sprite adr
LDA #0
STA 8
STA 9
STA 10
; DRAW SPRITE
JSR SPRITE_DRAW
; SWAP VIDEO SCREENS
JSR VIDEO_FLIP
; CONTINUE MAIN LOOP
JMP MAIN
; ********************************************************************************
; *** SWAP VIDEO SCREEN ON NEXT VERTICAL SYNC
; ********************************************************************************
VIDEO_FLIP:
; WAIT FOR VERTICAL SYNC LO
WAIT_SYNC_LO:
LDA 564
BIT #1
BNE WAIT_SYNC_LO ; was bne
; WAIT FOR VERTICAL SYNC HI
WAIT_SYNC_HI:
LDA 564
BIT #1
BNE WAIT_SYNC_HI
; FLIP VIDEO SCREENS
STA 512
; RETURN TO CALLER
RTS
; ********************************************************************************
; *** PLOT SINGLE PIXEL TO VIDEO MEMORY
; ********************************************************************************
; *** ZP00 : DESTINATION LOCATION X1.LO
; *** ZP01 : DESTINATION LOCATION X1.HI
; *** ZP02 : DESTINATION LOCATION Y1.LO
; *** ZP03 : DESTINATION LOCATION Y1.HI
; *** ZP04 : PIXEL COLOR VALUE
; ********************************************************************************
VIDEO_PLOT:
; SET DESTINATION LOCATION X1
LDA 0
STA 517
LDA 1
STA 518
; SET DESTINATION LOCATION Y1
LDA 2
STA 513
LDA 3
STA 514
; SET PIXEL COLOR VALUE
LDA 4
STA 529
; RETURN TO CALLER
RTS
; ********************************************************************************
; *** PLOT SINGLE PIXEL TO SPRITE MEMORY
; ********************************************************************************
; *** ZP00 : SPRITE SOURCE ADDRESS LO
; *** ZP01 : SPRITE SOURCE ADDRESS MD
; *** ZP02 : SPRITE SOURCE ADDRESS HI
; *** ZP03 : PIXEL COLOR VALUE
; ********************************************************************************
SPRITE_PLOT:
; SET SPRITE MEMORY ADDRESS
LDA 0
STA 530
LDA 1
STA 531
LDA 2
STA 532
; SET PIXEL COLOR VALUE
LDA 3
STA 533
; RETURN TO CALLER
RTS
; ********************************************************************************
; *** DRAW SPRITE TO THE VIDEO MEMORY
; ********************************************************************************
; *** ZP00 : DESTINATION LOCATION X.LO
; *** ZP01 : DESTINATION LOCATION X.HI
; *** ZP02 : DESTINATION LOCATION Y.LO
; *** ZP03 : DESTINATION LOCATION Y.HI
; *** ZP04 : SPRITE WIDTH VALUE X.LO
; *** ZP05 : SPRITE WIDTH VALUE X.HI
; *** ZP06 : SPRITE HEIGHT VALUE Y.LO
; *** ZP07 : SPRITE HEIGHT VALUE Y.HI
; *** ZP08 : SPRITE MEMORY ADDRESS LO
; *** ZP09 : SPRITE MEMORY ADDRESS MD
; *** ZP10 : SPRITE MEMORY ADDRESS HI
; ********************************************************************************
SPRITE_DRAW:
; SET SPRITE DESTINATION X1
LDA 0
STA 517
LDA 1
STA 518
; CALCULATE SPRITE WIDTH
CLC
LDA 0
ADC 4
STA 4
LDA 1
ADC 5
STA 5
; SET SPRITE DESTINATION X2
LDA 4
STA 519
LDA 5
STA 528
; SET SPRITE DESTINATION Y1
LDA 2
STA 513
LDA 3
STA 514
; CALCULATE SPRITE HEIGHT
CLC
LDA 2
ADC 6
STA 6
LDA 3
ADC 7
STA 7
; SET SPRITE DESTINATION Y2
LDA 6
STA 515
LDA 7
STA 516
; SET SPRITE MEMORY ADDRESS
LDA 8
STA 530
LDA 9
STA 531
LDA 10
STA 532
; SELECT SPRITE MEMORY (2)
LDA #2
STA 549
; EXECUTE GPU SPRITE
STA 534
; WAIT FOR GPU READY
SPRITE_RDY:
LDA 564
BIT #2
BNE SPRITE_RDY
; DESELECT SPRITE MEMORY (0)
LDA #0
STA 549
; RETURN TO CALLER
RTS
; ********************************************************************************
; *** SET SPRITE ALPHA COLOR
; *** ZP000 : SPRITE ALPHA COLOR
; ********************************************************************************
SPRITE_ALPHA:
; SET SPRITE ALPHA COLOR
LDA #0
STA 535
; RETURN TO CALLER
RTS
; ********************************************************************************
; *** PLOT SINGLE PIXEL TO PLAYFIELD MEMORY
; *** ZP000 : DESTINATION LOCATION X1.LO
; *** ZP001 : DESTINATION LOCATION X1.HI
; *** ZP002 : DESTINATION LOCATION Y1.LO
; *** ZP003 : DESTINATION LOCATION Y1.HI
; *** ZP004 : PIXEL COLOR VALUE
; ********************************************************************************
PLAYFIELD_PLOT:
; SET SPRITE DESTINATION LOCATION X1
LDA 0
STA 544
LDA 1
STA 545
; SET SPRITE DESTINATION LOCATION Y1
LDA 2
STA 547
LDA 3
STA 548
; SET SPRITE PIXEL COLOR VALUE
LDA 4
STA 550
; RETURN TO CALLER
RTS
; ********************************************************************************
; *** DRAW THE PLAYFIELD TO THE VIDEO MEMORY
; ********************************************************************************
PLAYFIELD_DRAW:
; SET PLAYFIELD SOURCE LOCATION X
LDA #0
STA 544
LDA #0
STA 545
; SET PLAYFIELD SOURCE LOCATION Y
LDA #0
STA 547
LDA #0
STA 548
; SET PLAYFIELD START LOCATION Y
LDA 4
STA 560
LDA 5
STA 561
; SET PLAYFIELD END LOCATION Y
LDA 6
STA 562
LDA 7
STA 563
; SELECT PLAYFIELD MEMORY (3)
LDA #3
STA 549
; EXECUTE GPU PLAYFIELD
STA 551
; READ VIDEO STATUS REGISTER AND WAIT FOR GPU READY
WAIT_GPU_READY:
LDA 564
AND #2
CMP #0
BNE WAIT_GPU_READY
; DESELECT PLAYFIELD MEMORY (0)
LDA #0
STA 549
; RETURN TO CALLER
RTS
DELAY:
LDX #0
LDY #100
dp1:
dex
BNE dp1
DEY
BNE dp1
rts
BALLS:
.BYTE 0,0,0,0,0,0,0,0,0,0,0,9,82,99,100,108,108,108,99,90,9,0,0,0,0,0,0,0,0,0,0,0
.BYTE 0,0,0,0,0,0,0,0,0,18,108,181,181,181,181,181,181,181,181,181,181,108,90,8,0,0,0,0,0,0,0,0
.BYTE 0,0,0,0,0,0,0,9,107,181,181,181,181,181,181,181,181,181,181,181,181,181,181,108,17,0,0,0,0,0,0,0
.BYTE 0,0,0,0,0,0,17,108,116,108,116,116,116,116,116,116,116,116,116,116,116,108,108,108,108,25,0,0,0,0,0,0
.BYTE 0,0,0,0,0,25,107,116,108,116,116,116,116,116,116,116,116,116,116,116,108,108,108,108,108,107,25,8,0,0,0,0
.BYTE 0,0,0,0,25,43,108,108,108,116,116,116,116,116,116,116,116,116,108,108,108,108,108,108,107,108,34,25,0,0,0,0
.BYTE 0,0,0,17,34,107,107,108,108,116,116,116,116,116,116,116,116,108,108,108,107,107,107,107,107,107,107,25,25,0,0,0
.BYTE 0,0,17,34,34,107,107,107,116,116,116,125,117,116,116,116,108,107,107,107,107,107,107,99,99,99,107,34,25,17,0,0
.BYTE 0,8,34,33,34,107,107,116,116,125,190,190,190,189,125,116,116,107,107,107,43,43,35,34,34,34,35,34,33,33,9,0
.BYTE 0,18,34,34,42,107,107,116,125,190,255,255,255,255,190,124,116,107,107,43,43,42,34,34,34,34,34,34,25,25,25,0
.BYTE 0,34,34,34,42,43,107,116,189,255,255,255,255,255,190,125,116,107,43,43,42,42,34,34,34,34,34,34,25,25,25,8
.BYTE 9,34,42,42,42,43,107,116,189,255,255,255,255,255,254,125,116,107,43,42,42,42,42,42,34,34,34,33,25,25,33,17
.BYTE 26,34,42,42,42,42,43,116,189,255,255,255,255,255,190,125,116,115,43,42,42,42,42,42,34,34,34,33,25,25,33,25
.BYTE 26,34,34,42,42,42,43,51,124,190,255,255,255,255,189,124,115,43,43,42,42,42,42,34,34,34,33,33,25,25,34,25
.BYTE 34,34,34,42,42,42,43,43,115,124,189,190,190,189,124,116,115,43,43,42,42,42,42,34,34,34,33,33,25,25,34,25
.BYTE 34,42,34,34,42,42,43,43,43,115,124,124,124,124,116,115,51,43,43,42,42,34,34,34,34,34,33,33,25,33,34,25
.BYTE 34,34,34,34,42,42,42,43,43,43,43,116,116,115,115,115,43,43,42,42,42,34,34,34,34,33,33,33,33,33,42,25
.BYTE 34,34,34,34,34,42,42,42,42,43,43,43,115,115,43,43,42,42,42,42,34,34,34,34,34,33,33,33,25,34,42,17
.BYTE 34,34,42,34,34,42,42,42,42,42,42,43,43,43,42,42,42,42,42,42,34,34,34,33,33,33,33,33,34,42,34,17
.BYTE 26,34,42,34,34,34,34,42,42,42,43,43,43,43,42,42,42,42,42,34,34,34,34,33,33,33,34,34,42,42,25,17
.BYTE 17,34,34,34,34,34,34,34,42,42,42,42,42,42,42,42,42,42,34,34,34,34,34,34,34,34,34,34,42,34,25,9
.BYTE 8,34,34,34,34,34,34,34,42,42,34,34,34,42,42,42,42,42,34,34,34,34,34,34,34,34,34,34,42,25,17,8
.BYTE 0,26,34,34,34,34,34,34,34,34,34,34,34,34,34,34,34,34,34,34,34,34,34,34,34,34,34,34,34,17,17,0
.BYTE 0,9,34,34,34,34,34,34,34,34,34,34,34,34,34,34,34,34,34,34,34,34,34,34,34,34,34,25,17,17,8,0
.BYTE 0,0,17,34,34,34,34,34,34,34,34,34,34,34,34,34,34,34,34,34,34,34,34,34,34,25,25,17,17,9,0,0
.BYTE 0,0,0,26,34,34,34,34,34,33,33,33,33,33,33,33,33,33,33,33,33,33,25,25,25,17,17,17,17,0,0,0
.BYTE 0,0,0,8,25,34,34,34,34,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,17,17,17,17,0,0,0,0
.BYTE 0,0,0,0,8,25,33,33,33,25,25,25,25,25,25,25,25,25,25,25,25,25,17,17,17,17,17,8,0,0,0,0
.BYTE 0,0,0,0,0,0,17,25,25,25,25,25,25,25,25,25,25,25,25,17,17,17,17,17,17,17,0,0,0,0,0,0
.BYTE 0,0,0,0,0,0,0,17,25,25,25,25,17,17,17,17,17,17,17,17,17,17,17,17,8,0,0,0,0,0,0,0
.BYTE 0,0,0,0,0,0,0,0,8,17,25,25,25,17,17,17,17,17,17,17,17,17,9,8,0,0,0,0,0,0,0,0
.BYTE 0,0,0,0,0,0,0,0,0,0,8,8,17,17,17,17,17,16,8,8,8,0,0,0,0,0,0,0,0,0,0,0
5) After running the batch file, I get a file called Cartridge.bin, but it is 512 bytes shy due to limitations in CC65.
6) I run my Vulcan-74 BIN to AVR converter, which makes an AVR loadable image and pads back the missing 512 bytes.
7) This is then loaded into the AVR that boot loads the 6502 Program Memory, and the balls begin to bounce!As soon as I get all the required C foo under control I will then make this all automated within my Vulcan-74 ToolKit.
Things I know (less than) nothing about (yet) are the definitions for a C program to run. BSS, Heap, etc.
If time permits, I will have this all working tomorrow.
The goal will be to remove the ball bouncer from the Library, and have it working as a C program, calling the assembly routines.
Ok, back at it.... there are at least dozen more Yaks that still have hair!
Radical Brad