Code: Select all
void main (void) {
unsigned char *screen = (unsigned char *)7680;
screen[0] = 81; // petscii ball character in upper left
}
Moderator: Moderators
Code: Select all
void main (void) {
unsigned char *screen = (unsigned char *)7680;
screen[0] = 81; // petscii ball character in upper left
}
I'm sorry, but I need to be nitpicky quite at this stage already. The C standard says there are two valid prototypes for main():JavaJack59 wrote:I don't need params passed to main
Code: Select all
int main(void);
int main(int argc, char* argv[]);
Code: Select all
LDA #$51
STA $1E00
[...]
ThanksMike wrote:First of all, welcome to Denial!
Hmm. Was there a good rationale for making this a recompile issue for the compiler itself, rather than using an .asm file for the startup code and assembling it at compile time? I'm no expert, but this seems... odd. Or I'm misunderstanding your comment.Mike wrote:you'd need to recompile cc65 and reassemble the startup stub
That's perfectly acceptable for my use case. The actual program would make use of for/if/while and arrays. And yeah, I was already aware of the color thing.Mike wrote:Your C fragment would create the variable 'screen' on the stack and copy it to the zeropage to make it available as pointer for the (ZP),Y addressing mode.
Only if I want a 20-fold increase in development time, since I've never written more than 3 or 4 lines of 6502.Mike wrote:I suppose ca65 is more the right tool for the job.
Mike wrote:you'd need to recompile cc65 and reassemble the startup stub
O.K., maybe not quite recompiling cc65 itself, but the relevant *.s file is usually not re-assembled at compile time, neither. Normally, a cc65 installation would refer to 'vic20.lib' as soon as you're going to build anything for the VIC-20. That library contains a collection of pre-assembled *.s and pre-compiled *.c files for the runtime and C library.JavaJack59 wrote:Hmm. Was there a good rationale for making this a recompile issue for the compiler itself, rather than using an .asm file for the startup code and assembling it at compile time? I'm no expert, but this seems... odd. Or I'm misunderstanding your comment.
Thus far you didn't tell what you are up to. That stripped down C dialect that you're going to use won't be nearly as efficient as machine language on the 6502, and you will miss out those routines in the C library that actually have been crafted in machine code (using ca65) instead of being compiled from C source.Only if I want a 20-fold increase in development time, since I've never written more than 3 or 4 lines of 6502.
A digital clock program. Read the jiffy clock and display it as large fixed petscii-art digits. The digits themselves wouldn't even need to change. Segments would be turned on/off by updating color RAM.Mike wrote:Thus far you didn't tell what you are up to.
In that case, the thread 'Display of TI$ in border (unex. or +3K)' might be worth a look.JavaJack59 wrote:A digital clock program. Read the jiffy clock and display it [...]
Code: Select all
$ cat test.c
void start(void)
{
asm("inc $d020");
}
$ cl65 -o test.bin -t none test.c
$ hex test.bin
0000 ee 20 d0 60
That looked promising, but I just ended up with a bunch of "Unresolved external" errors.groepaz wrote:just use -t none for no startup code and instead of main() use start():
Code: Select all
.import _main
.import __RAM_START__, __RAM_SIZE__ ; Linker generated
.export __STARTUP__ : absolute = 1 ; Mark as startup
.include "zeropage.inc"
.segment "STARTUP"
.word $1001; Load address
.byte $0B, $10, $00, $00, $9E, '4','1','0','9',$00, $00, $00
lda #<(__RAM_START__ + __RAM_SIZE__)
sta sp
lda #>(__RAM_START__ + __RAM_SIZE__)
sta sp+1
jsr _main
Code: Select all
typedef unsigned char byte;
#define SCREEN_ADDR (0x1E00)
#define COL_ADDR (0x9600)
byte* ptr_screen;
byte* ptr_color;
void main()
{
ptr_screen = SCREEN_ADDR;
ptr_color = COL_ADDR;
ptr_screen[1] = 0x01;
ptr_color[1] = 0x02;
ptr_screen[2] = 0x02;
ptr_color[2] = 0x03;
loop:
goto loop;
}
Code: Select all
;
; File generated by cc65 v 2.13.2
;
.fopt compiler,"cc65 v 2.13.2"
.setcpu "6502"
.smart on
.autoimport on
.case on
.debuginfo off
.importzp sp, sreg, regsave, regbank, tmp1, ptr1, ptr2
.macpack longbranch
.forceimport __STARTUP__
.export _ptr_screen
.export _ptr_color
.export _main
.segment "BSS"
_ptr_screen:
.res 2,$00
_ptr_color:
.res 2,$00
; ---------------------------------------------------------------
; void __near__ main (void)
; ---------------------------------------------------------------
.segment "CODE"
.proc _main: near
.segment "CODE"
ldx #$1E
lda #$00
sta _ptr_screen
stx _ptr_screen+1
ldx #$96
lda #$00
sta _ptr_color
stx _ptr_color+1
lda _ptr_screen
ldx _ptr_screen+1
jsr pushax
ldx #$00
lda #$01
ldy #$01
jsr staspidx
lda _ptr_color
ldx _ptr_color+1
jsr pushax
ldx #$00
lda #$02
ldy #$01
jsr staspidx
lda _ptr_screen
ldx _ptr_screen+1
jsr pushax
ldx #$00
lda #$02
ldy #$02
jsr staspidx
lda _ptr_color
ldx _ptr_color+1
jsr pushax
ldx #$00
lda #$03
ldy #$02
jsr staspidx
L0015: jmp L0015
rts
.endproc
Yeah. I ended up with this:Mike wrote:missing the necessary *.cfg file
Code: Select all
E:\coding\cc65\min>ld65 main.o vic20_minimal.o
ld65: Error: Memory configuration missing
PERFECT.Misfit wrote:project files
Agreed.Misfit wrote:Sometimes it's better to use more memory if it is the only way to create a finished product.
not really. he made a small crt0 which basically removes the heap, and doesnt use the interrupt chain stuff. both of which you dont want to use in a memory constrained environment anyway - i have done the same for all c64 programs i made with cc65.Dumbing down cc65 for this kind of use is really like using a hammer to turn a screw.
try with -Osir the generated code is large in some cases, but its not *that* bad reallyThe equivalent assembly code (excluding the BASIC stub) would only use 4 LDAs and 4 STAs.