-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
draft: connecting button signals #16
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,28 +19,38 @@ int ge_init(struct ge *ge) | |
{ | ||
memset(ge, 0, sizeof(*ge)); | ||
ge->halted = 1; | ||
ge->console.lamps.LP_POWER_ON = 1; | ||
ge->console.lamps.LP_HALT = 1; | ||
ge->ticks = 0; | ||
return 0; | ||
} | ||
|
||
int ge_halt(struct ge *ge) | ||
{ | ||
if ((ge->halted == 0) && (ge->console.buttons.B_HALT_START)) { | ||
ge->halted = 1; | ||
printf("HALTED\n"); | ||
} | ||
} | ||
|
||
/// Emulate the press of the "clear" button in the console | ||
void ge_clear(struct ge *ge) | ||
{ | ||
// From 14023130-0, sheet 5: | ||
// The pressure of the "CLEAR" push button only determines the continuos | ||
// performance of the "00" status | ||
ge->rSO = 0; | ||
if (ge->console.buttons.B_CLEAR) { | ||
// From 14023130-0, sheet 5: | ||
// The pressure of the "CLEAR" push button only determines the continuos | ||
// performance of the "00" status | ||
ge->rSO = 0; | ||
|
||
/* From 30004122 o/A, sheet 31: | ||
* The light is switched off by tle LOFF instruction or by the CLEAR key */ | ||
ge->operator_call = 0; | ||
/* From 30004122 o/A, sheet 31: | ||
* The light is switched off by tle LOFF instruction or by the CLEAR key */ | ||
ge->operator_call = 0; | ||
|
||
// Also clear the emulated memory... what else?! | ||
memset(ge->mem, 0, sizeof(ge->mem)); | ||
// Also clear the emulated memory... what else?! | ||
memset(ge->mem, 0, sizeof(ge->mem)); | ||
|
||
ge->AINI = 0; | ||
ge->AINI = 0; | ||
|
||
printf("CLEAR\n"); | ||
} | ||
} | ||
|
||
/// Emulate the press of the "load" button in the console | ||
|
@@ -49,38 +59,44 @@ int ge_load(struct ge *ge, uint8_t *program, uint8_t size) | |
if (program == NULL && size != 0) | ||
return -1; | ||
|
||
/* When pressing LOAD button, AINI is set. If AINI is set, the state 80 | ||
* (initialitiation) goes to state c8, starting the loading of the program | ||
* (of max 129 words) from one of the peripherc unit. */ | ||
if (ge->console.buttons.B_LOAD) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure if checking the buttons here is the right approach. |
||
|
||
/* set AINI FF to 1 (pag. 96)*/ | ||
ge->AINI = 1; | ||
if (program != NULL) { | ||
if (size > MAX_PROGRAM_STORAGE_WORDS) | ||
size = MAX_PROGRAM_STORAGE_WORDS; | ||
/* When pressing LOAD button, AINI is set. If AINI is set, the state 80 | ||
* (initialitiation) goes to state c8, starting the loading of the program | ||
* (of max 129 words) from one of the peripherc unit. */ | ||
|
||
/* simulate the loading for now */ | ||
memcpy(ge->mem, program, size); | ||
/* set AINI FF to 1 (pag. 96)*/ | ||
ge->AINI = 1; | ||
if (program != NULL) { | ||
if (size > MAX_PROGRAM_STORAGE_WORDS) | ||
size = MAX_PROGRAM_STORAGE_WORDS; | ||
|
||
/* I'm supposing that the AINI signal is resetted after loading */ | ||
ge->AINI = 0; | ||
} | ||
/* simulate the loading for now */ | ||
memcpy(ge->mem, program, size); | ||
|
||
/* I'm supposing that the AINI signal is resetted after loading */ | ||
ge->AINI = 0; | ||
} | ||
printf("LOAD\n"); | ||
} | ||
return 0; | ||
} | ||
|
||
/// Emulate the press of the "start" button in the console | ||
int ge_start(struct ge *ge) | ||
{ | ||
// From 14023130-0, sheet 5: | ||
// With the rotating switch in "NORM" position, after the operation | ||
// "CLEAR-LOAD-START" or "CLEAR-START", the 80 status is performed. | ||
ge->rSO = 0x80; | ||
ge->console.rotary = RS_NORM; | ||
|
||
ge->halted = 0; | ||
ge->console.lamps.LP_HALT = 0; | ||
|
||
if ((ge->console.buttons.B_HALT_START) && (ge->halted)) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. as above, should this function be invoked if the button is pressed? |
||
// From 14023130-0, sheet 5: | ||
// With the rotating switch in "NORM" position, after the operation | ||
// "CLEAR-LOAD-START" or "CLEAR-START", the 80 status is performed. | ||
if (ge->console.rotary != RS_NORM) { | ||
printf("Console switch not in NORM position.\n"); | ||
return 0; | ||
} | ||
ge->rSO = 0x80; | ||
|
||
ge->halted = 0; | ||
} | ||
return 0; | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,14 +20,17 @@ int main(int argc, char *argv[]) | |
/* load with memory / and or setup peripherics */ | ||
|
||
while(1) { | ||
console_socket_check(&ge130); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we have something like:
|
||
ge_clear(&ge130); | ||
ge_load(&ge130, &test_program, 1); | ||
ge_start(&ge130); | ||
Comment on lines
+23
to
26
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we should separate these two ways of running the emulator, I think we can have an option to enable the console, and in this case, clear/load/start are only managed through the console, otherwise, a simpler clear/load/start like the one we have now is used. |
||
|
||
ret = ge_run(&ge130); | ||
if (!ge130.halted) | ||
ret = ge_run(&ge130); | ||
|
||
ge_halt(&ge130); | ||
sleep(1); | ||
printf(" *** RESTART *** "); | ||
printf(" *** RESTART *** \n"); | ||
} | ||
ge_deinit(&ge130); | ||
return ret; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think using some console_socket functions is a good way to interact with the console when ge isn't running.