Skip to content

Commit

Permalink
Autoconfigure RAM for emulator
Browse files Browse the repository at this point in the history
Autoconfigure RAM for emulator based on MCU's free memory
  • Loading branch information
Bakisha authored Aug 8, 2020
1 parent 7bd0794 commit 230efab
Show file tree
Hide file tree
Showing 19 changed files with 811 additions and 794 deletions.
16 changes: 13 additions & 3 deletions SD_CARD/STM32SID_FOLDER-PLAYER_SDCARD_BUTTON1/02_ram.ino
Original file line number Diff line number Diff line change
@@ -1,12 +1,22 @@


#if defined(SPI_RAM)
// TODO
#elif defined(PARALLEL_SRAM)
#if defined(SPI_RAM)
// TODO
#elif defined(PARALLEL_SRAM)
// TODO
#else
// internal RAM

void AllocateRAM() {
if ((FreeBytes()) > 0xffff ) {
RAM_SIZE = 0xffff;
}
else {
RAM_SIZE = FreeBytes() - 2048;
}
RAM = (uint8_t*) calloc(RAM_SIZE, sizeof(uint8_t)); // allocate memory
}

inline void POKE (uint16_t addr , uint8_t bytE ) {

RAM[addr] = bytE;
Expand Down
34 changes: 17 additions & 17 deletions SD_CARD/STM32SID_FOLDER-PLAYER_SDCARD_BUTTON1/03_6502.ino
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ inline uint8_t read6502(uint16_t address) {
JSR1003 = 1; // if it's loading <20-03-10> (example: JSR $1003) value from sid_play routine, it is time for fake VIC-II irq signal
}
if ((address >= 0xD400) && (address < 0xD420)) {

STAD4XX = 1; // sid read
return_value = SID[address - 0xD400]; // TODO: make it unreadable // SID
}
Expand All @@ -39,19 +39,19 @@ inline uint8_t read6502(uint16_t address) {

if ( address < (0x400) ) return_value = PEEK (address) ; // zero page, stack, player, screen RAM

//CIA timer
//CIA timer
if ( address == 0xdc04 ) {
return_value = CIA_DC04;
}
if ( address == 0xdc05 ) {
return_value = CIA_DC05;
}
return_value = CIA_DC04;
}
if ( address == 0xdc05 ) {
return_value = CIA_DC05;
}





return return_value;
return return_value;

}

Expand Down Expand Up @@ -292,16 +292,16 @@ inline void write6502(uint16_t address, uint8_t value) {
} // LOW_RAM


//CIA timer
//CIA timer
if ( address == 0xdc04 ) {
CIA_DC04=value;
}
if ( address == 0xdc05 ) {
CIA_DC05=value;
}
if (CIA_DC05>0) { // set song speed only when Hi value of CIA timer is greater then 0
set_tune_speed ();
}
CIA_DC04 = value;
}
if ( address == 0xdc05 ) {
CIA_DC05 = value;
}
if (CIA_DC05 > 0) { // set song speed only when Hi value of CIA timer is greater then 0
set_tune_speed ();
}

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ inline bool Compatibility_check() {
if (SID_load_start == 0) {
SID_load_start = PEEK (0x7c + 0x380) + (PEEK (0x7d + 0x380) * 256);
}
if ( SID_load_start >= 0x07E8) {
if ( SID_load_start >= 0x0400) { // >= 0x07E8) {
LOAD_ADDRESS = SID_load_start;
}

Expand Down
Loading

0 comments on commit 230efab

Please sign in to comment.