-
Notifications
You must be signed in to change notification settings - Fork 2
implement network interrupts for Atari version. #6
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
Open
tschak909
wants to merge
4
commits into
main
Choose a base branch
from
implement_atari_intr
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 2 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| ;; Simple interrupt handler for PROCEED | ||
| ;; Sets "trip" variable to 1 when triggered. | ||
|
|
||
| .export _ih | ||
| .import _trip | ||
|
|
||
| _ih: lda #$01 ; Assign 1 | ||
| sta _trip ; to trip | ||
| pla ; Pull parameter off stack. | ||
| rti ; Return to main program. | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,6 +17,14 @@ extern void vt100_screen_rows; | |
| #pragma zpsym ("vt100_screen_cols"); | ||
| #pragma zpsym ("vt100_screen_rows"); | ||
|
|
||
| #if defined(__ATARI__) | ||
| bool trip=false; /* Used for PROCEED interrupt. */ | ||
| uint8_t old_enabled=0; /* Saved interrupt state */ | ||
| uint8_t old_connected=false; /* Old connected state */ | ||
| void *old_vprced; /* Saved PROCEED interrupt vector */ | ||
| extern void ih(); /* PROCEED interrupt handler */ | ||
| #endif /* __ATARI__*/ | ||
|
|
||
| #if defined(__ATARI__) || defined(__C64__) | ||
| int16_t get_key_if_available(void); | ||
| #endif | ||
|
|
@@ -40,13 +48,49 @@ void __fastcall__ vt100_send_string(uint8_t *s) { | |
| network_write(device, s, strlen((char *)s)); | ||
| } | ||
|
|
||
| /** | ||
| * @brief Set up network interrupts, if available. | ||
| */ | ||
| void network_interrupt_enable(void) | ||
| { | ||
| #if defined(__ATARI__) | ||
| old_vprced = OS.vprced; /* Store old VPRCED vector for exit */ | ||
| old_enabled = PIA.pactl & 1; /* Keep track of old interrupt state */ | ||
| PIA.pactl &= (~1); /* Turn off interrupts momentarily. */ | ||
| OS.vprced = ih; /* Set interrupt handler. */ | ||
| PIA.pactl |= 1; /* Tell PIA we are ready. */ | ||
| #endif /* __ATARI__*/ | ||
| } | ||
|
|
||
| /** | ||
| * @brief Tear down interrupt when we're exiting. | ||
| */ | ||
| void network_interrupt_disable(void) | ||
| { | ||
| #if defined(__ATARI__) | ||
| PIA.pactl &= (~1); /* Disable interrupts. */ | ||
| OS.vprced = old_vprced; /* Bring back old PROCEED vector */ | ||
| PIA.pactl |= old_enabled; /* Bring back original PACTL state. */ | ||
| #endif /* __ATARI__ */ | ||
| } | ||
|
|
||
| static bool connected(void) | ||
| { | ||
| uint16_t bw; | ||
| uint8_t c; | ||
| uint8_t err; | ||
|
|
||
| #if defined(__ATARI__) | ||
| if (!trip) | ||
| return old_connected; | ||
| #endif /* __ATARI__ */ | ||
|
|
||
| network_status(device, &bw, &c, &err); | ||
|
|
||
| #if defined(__ATARI__) | ||
| old_connected = c; | ||
| #endif /* __ATARI__ */ | ||
|
|
||
| return c; | ||
| } | ||
|
|
||
|
|
@@ -120,30 +164,47 @@ void main(int argc, char *argv[]) | |
| puts(device + 2); | ||
| quit(); | ||
| } | ||
|
|
||
| /* Only enable interrupts when we are successfully connected. */ | ||
| network_interrupt_enable(); | ||
|
|
||
| vt100_init_terminal(); | ||
|
|
||
| while (connected()) { | ||
|
|
||
| #if defined(__ATARI__) | ||
| if (!trip) | ||
| goto read_atari_keyboard; | ||
| #endif /* __ATARI__ */ | ||
|
|
||
| retval = network_read_nb(device, buffer, sizeof(buffer)); | ||
| if (retval > 0) { | ||
| bufptr = buffer; | ||
| while (retval--) { | ||
| vt100_process_inbound_char(*bufptr++); | ||
| } | ||
| } | ||
|
|
||
| #if defined(__ATARI__) || defined(__C64__) | ||
| read_atari_keyboard: | ||
| retval = get_key_if_available(); | ||
| if (retval >= 0) { | ||
| vt100_process_outbound_char(retval); | ||
| } | ||
|
|
||
| trip = 0; /* Clear the trip wire. */ | ||
|
||
| PIA.pactl |= 1; /* Interrupt serviced, ready for next one. */ | ||
|
|
||
| #else | ||
| if (kbhit()) { | ||
| vt100_process_outbound_char(cgetc()); | ||
| } | ||
| #endif | ||
| } | ||
|
|
||
| /* Disable interrupts */ | ||
| network_interrupt_disable(); | ||
|
|
||
| vt100_exit_terminal(); | ||
|
|
||
| puts("Connection closed."); | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
this is only defined for ATARI, but you later use it in a block for ATARI or C64.
I don't think this compiles.