Skip to content

Commit

Permalink
implement lpoke/lpeek with compound instructions
Browse files Browse the repository at this point in the history
  • Loading branch information
ki-bo committed Jun 1, 2023
1 parent 49cae7e commit 87ae766
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 7 deletions.
3 changes: 2 additions & 1 deletion cc65/include/memory.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,11 @@ extern struct dmagic_dmalist dmalist;
extern unsigned char dma_byte;

void mega65_io_enable(void);
unsigned char qpeek(long address);
unsigned char lpeek(long address);
unsigned char lpeek_debounced(long address);
unsigned char dma_peek(long address);
void lpoke(long address, unsigned char value);
void dma_poke(long address, unsigned char value);
void lcopy(long source_address, long destination_address,
unsigned int count);
void lfill(long destination_address, unsigned char value,
Expand Down
4 changes: 2 additions & 2 deletions cc65/src/memory.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ void do_dma(void)
POKE(0xd705U, ((unsigned int)&dmalist) & 0xff); // triggers enhanced DMA
}

unsigned char lpeek(long address)
unsigned char dma_peek(long address)
{
// Read the byte at <address> in 28-bit address space
// XXX - Optimise out repeated setup etc
Expand Down Expand Up @@ -65,7 +65,7 @@ unsigned char lpeek_debounced(long address)
return db1;
}

void lpoke(long address, unsigned char value)
void dma_poke(long address, unsigned char value)
{

dmalist.option_0b = 0x0b;
Expand Down
28 changes: 24 additions & 4 deletions cc65/src/memory_asm.s
Original file line number Diff line number Diff line change
@@ -1,12 +1,32 @@
.export _qpeek
.export _lpoke, _lpeek

.importzp sreg,tmp1,tmp2,tmp3,tmp4
.p02

.p4510
.importzp sp,sreg,tmp1,tmp2,tmp3,tmp4
.import incsp4

.proc _qpeek: near
.p4510

.segment "CODE"

.proc _lpoke: near
pha
neg
neg
.p02
lda sp
.p4510
neg
neg
sta tmp1
ldz #$00
pla
nop
sta (tmp1),z
jmp incsp4
.endproc

.proc _lpeek: near
sta tmp1
stx tmp2
lda sreg
Expand Down

0 comments on commit 87ae766

Please sign in to comment.