Add raster IRQ handler for cartridge with ROM switching

This commit is contained in:
drmortalwombat 2024-10-01 09:45:41 +02:00
parent 5126ba482e
commit 62ab925e01
4 changed files with 96 additions and 12 deletions

View File

@ -29,7 +29,7 @@ __asm irq0
pha
tya
pha
kentry:
asl $d019
ldx nextIRQ
@ -57,14 +57,15 @@ ji:
// carry is cleared at this point
tay
dey
sbc #2
cmp $d012
bcc l1
exd:
dey
ex:
sty $d012
ex:
pla
tay
pla
@ -77,20 +78,16 @@ e2:
ldx npos
stx tpos
inc rirq_count
tay
bit $d011
bmi e1
sta $d012
jmp ex
bpl ex
e1:
ldx #0
stx nextIRQ
ldy rasterIRQNext
dey
sty $d012
jmp ex
jmp exd
}
@ -101,7 +98,7 @@ __asm irq2
pha
tya
pha
kentry:
lda $01
pha
@ -509,6 +506,42 @@ void rirq_init_kernal_io(void)
}
void rirq_init_crt(void)
{
rirq_init_tables();
__asm
{
sei
}
*(void **)0x0314 = irq0.kentry;
*(void **)0xfffe = irq0;
vic.intr_enable = 1;
vic.ctrl1 &= 0x7f;
vic.raster = 255;
}
void rirq_init_crt_io(void)
{
rirq_init_tables();
__asm
{
sei
}
*(void **)0x0314 = irq2.kentry;
*(void **)0xfffe = irq2;
vic.intr_enable = 1;
vic.ctrl1 &= 0x7f;
vic.raster = 255;
}
void rirq_init_io(void)
{
rirq_init_tables();

View File

@ -132,7 +132,8 @@ inline void rirq_data(RIRQCode * ic, byte n, byte data);
// Add a delay of 5 * cycles to a raster IRQ
inline void rirq_delay(RIRQCode * ic, byte cycles);
// Place a raster IRQ into one of the 16 slots
// Place a raster IRQ into one of the 16 slots, the interrupt will fire
// one line below the given row
inline void rirq_set(byte n, byte row, RIRQCode * write);
// Remove a raster IRQ from one of the 16 slots
@ -147,12 +148,28 @@ inline void rirq_move(byte n, byte row);
// the less resource hungry option)
inline void rirq_init(bool kernalIRQ);
// Raster IRQ through kernal, with IO range always enabled
// calls kernal continuation
void rirq_init_kernal(void);
// Raster IRQ through kernal, with IO range not always enabled
// calls kernal continuation
void rirq_init_kernal_io(void);
// Raster IRQ through RAM and ROM vector, with ROM disabled or not and IO range always enabled
// does not call kernal continuation
void rirq_init_crt(void);
// Raster IRQ through RAM and ROM vector, with ROM disabled or not and IO range not always enabled
// does not call kernal continuation
void rirq_init_crt_io(void);
// Raster IRQ through RAM vector, with ROM disabled and IO range always enabled
// does not call kernal continuation
void rirq_init_io(void);
// Raster IRQ through RAM vector, with ROM disabled and IO range not always enabled
// does not call kernal continuation
void rirq_init_memmap(void);
// Start raster IRQ

View File

@ -2223,6 +2223,23 @@ InterCodeGenerator::ExValue InterCodeGenerator::TranslateExpression(Declaration*
return ExValue(TheVoidPointerTypeDeclaration, ins->mDst.mTemp);
}
case DT_LABEL:
{
if (!dec->mBase->mLinkerObject)
TranslateAssembler(proc->mModule, dec->mBase->mValue, nullptr);
InterInstruction* ins = new InterInstruction(MapLocation(exp, inlineMapper), IC_CONSTANT);
ins->mDst.mType = IT_POINTER;
ins->mDst.mTemp = proc->AddTemporary(ins->mDst.mType);
ins->mConst.mType = IT_POINTER;
ins->mConst.mVarIndex = dec->mBase->mVarIndex;
ins->mConst.mLinkerObject = dec->mBase->mLinkerObject;
ins->mConst.mMemory = IM_PROCEDURE;
ins->mConst.mIntConst = dec->mInteger;
block->Append(ins);
return ExValue(TheVoidPointerTypeDeclaration, ins->mDst.mTemp);
}
case DT_CONST_POINTER:
{
vl = TranslateExpression(procType, proc, block, dec->mValue, destack, gotos, breakBlock, continueBlock, inlineMapper);

View File

@ -7064,6 +7064,23 @@ Expression* Parser::ParseQualify(Expression* exp)
else
mErrors->Error(mScanner->mLocation, EERR_SYNTAX, "Identifier expected");
}
else if (exp->mType == EX_CONSTANT && exp->mDecValue->mType == DT_CONST_ASSEMBLER)
{
if (mScanner->mToken == TK_IDENT)
{
Declaration* ldec = exp->mDecValue->mBase->mScope->Lookup(mScanner->mTokenIdent);
if (ldec)
{
exp->mDecValue = ldec;
exp->mDecType = TheUnsignedIntTypeDeclaration;
}
else
mErrors->Error(mScanner->mLocation, EERR_OBJECT_NOT_FOUND, "Assembler label not found", mScanner->mTokenIdent);
mScanner->NextToken();
}
else
mErrors->Error(mScanner->mLocation, EERR_SYNTAX, "Identifier expected");
}
else
mErrors->Error(mScanner->mLocation, EERR_INCOMPATIBLE_OPERATOR, "Struct expected");