{"id":37513758,"url":"https://github.com/sandord/ikbd4gfa","last_synced_at":"2026-01-16T08:05:15.080Z","repository":{"id":321181561,"uuid":"1084553397","full_name":"sandord/ikbd4gfa","owner":"sandord","description":"IKBD routines for keyboard and joystick handling, for use with GFA Basic on the Atari ST. Aimed at game development.","archived":false,"fork":false,"pushed_at":"2025-10-28T09:15:38.000Z","size":18,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-10-28T09:28:49.107Z","etag":null,"topics":["atari-st","gfabasic","retrocomputing"],"latest_commit_sha":null,"homepage":"","language":"Assembly","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"cc0-1.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sandord.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-10-27T20:49:09.000Z","updated_at":"2025-10-28T09:17:47.000Z","dependencies_parsed_at":"2025-10-28T09:28:50.552Z","dependency_job_id":null,"html_url":"https://github.com/sandord/ikbd4gfa","commit_stats":null,"previous_names":["sandord/ikbd4gfa"],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/sandord/ikbd4gfa","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sandord%2Fikbd4gfa","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sandord%2Fikbd4gfa/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sandord%2Fikbd4gfa/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sandord%2Fikbd4gfa/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sandord","download_url":"https://codeload.github.com/sandord/ikbd4gfa/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sandord%2Fikbd4gfa/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28478047,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-16T06:30:42.265Z","status":"ssl_error","status_checked_at":"2026-01-16T06:30:16.248Z","response_time":107,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["atari-st","gfabasic","retrocomputing"],"created_at":"2026-01-16T08:05:14.966Z","updated_at":"2026-01-16T08:05:15.058Z","avatar_url":"https://github.com/sandord.png","language":"Assembly","funding_links":[],"categories":[],"sub_categories":[],"readme":"# IKBD4GFA\n\nUsing the default keyboard and joystick functions in GFA Basic on the Atari ST has its limitations.\n\nEspecially when developing games, you may find that you need a more performant and reliable way of handling keyboard and joystick input.\n\nThis repository contains IKBD routines for keyboard and joystick handling that can be used in GFA Basic.\n\n\u003e **IMPORTANT:** Please note that the mouse is turned off between `init` and `restore`. If you need mouse support, this library will not suit your needs in its current form.\n\n## Routines\n\nThe [dist/IKBD4GFA.INL](dist/IKBD4GFA.INL) file is an Atari ST binary, assembled from the [src/IKBD4GFA.S](src/IKBD4GFA.S) source using Devpac 3.\n\nThe following routines are available in the binary:\n\n| Routine                  | Offset | Description                                                                                                     | Returns         | Supervisor mode |\n|--------------------------|:------:|:----------------------------------------------------------------------------------------------------------------|-----------------|:---------------:|\n| `init`                   |  +$1c  | Initializes the IKBD. Must be called before other routines.                                                     | -               |       Yes       |\n| `restore`                |  +$20  | Restores the IKBD. Call before exiting your program.                                                            | -               |       Yes       |\n| `get_scancode_state_tbl` |  +$24  | Gets address of the scancode state table. Use scancode as index, `0` = unpressed, `1` = pressed.                | `a0` (address)  |       No        |\n| `get_ascii_state_tbl`    |  +$28  | Gets address of the ASCII state table. Use ASCII code as index, `0` = unpressed, `1` = pressed.                 | `a0` (address)  |       No        |\n| `get_last_scancode`      |  +$2c  | Returns the scancode of the last pressed key.                                                                   | `d0` (scancode) |       No        |\n| `get_joystick_states`    |  +$30  | Returns joystick states for joysticks 0 and 1 with joystick 0 state in the MSB and joystick 1 state in the LSB. | `d0` (states)   |       No        |\n| `interrogate_joysticks`  |  +$34  | Triggers joystick interrogation; states become available later and can be read with `get_joystick_states`.      | -               |       Yes       |\n\n## Usage\n\nTo use the routines in GFA Basic, you should inline the [dist/IKBD4GFA.INL](dist/IKBD4GFA.INL) file in your GFA Basic program:\n\n```basic\n' IKBD4GFA.INL. Make sure the number in the second parameter matches the size\n' of the .INL file exactly.\nINLINE ikbd%,978\n```\n\nYou can then load the `.INL` file in-line by pressing the `Help` key while the text cursor is on the `INLINE` keyword. Click on `Load` at the top of the screen and select the `.INL` file (it is located in the `/dist` directory of this repository).\n\nNext, add the following code that makes the routine calls easier to use.\n\n```basic\n' This array represents the CPU registers d0-d7/a0-a6.\nDIM reg%(15)\n'\nPROCEDURE init_ikbd\n  ~XBIOS(38,L:ikbd%+\u0026H1C) !init\nRETURN\nPROCEDURE restore_ikbd\n  ~XBIOS(38,L:ikbd%+\u0026H20) !restore\nRETURN\nFUNCTION get_scancode_state_table\n  RCALL ikbd%+\u0026H24,reg%() !get_scancode_state_tbl\n  RETURN reg%(8) !a0\nENDFUNC\nFUNCTION get_ascii_state_table\n  RCALL ikbd%+\u0026H28,reg%() !get_ascii_state_tbl\n  RETURN reg%(8) !a0\nENDFUNC\nFUNCTION get_last_scancode\n  RCALL ikbd%+\u0026H2c,reg%()\n  RETURN reg%(0) !d0\nENDFUNC\nFUNCTION get_joystick_states\n  RCALL ikbd%+\u0026H30,reg%() !get_joystick_states\n  RETURN reg%(0) !d0\nENDFUNC\nPROCEDURE interrogate_joysticks\n  ~XBIOS(38,L:ikbd%+\u0026H34) !interrogate_joysticks\nRETURN\n```\n\n\u003e As you can see, the same offsets from the routine table mentioned earlier, are used in the calls. Also, note that some calls are made using `XBIOS(38,...)`, which calls the routine in supervisor mode.\n\n## Demo code\n\nThe [demo/GFADEMO.LST](demo/GFADEMO.LST) file contains demo code for GFA Basic.\n\n\u003e The GFA source is present as a `.LST` file because it is in ASCII format while `.GFA` files are token-based. The token-based files wouldn't be previewable outside of the GFA Basic editor and they'd also make diffs and merges practically impossible.\n\nYou can load the `.LST` file into your GFA editor using the Merge option. Then you'll have to load the [dist/IKBD4GFA.INL](dist/IKBD4GFA.INL) file in-line (see instructions at [Usage](#usage)).\n\n## Credits\n\nThe excellent GODLIB has been a source of learning to me on the workings of the IKBD and how to properly implement an IKBD handler. See \u003chttps://github.com/ReservoirGods/GODLIB/blob/master/IKBD/IKBD_S.S\u003e.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsandord%2Fikbd4gfa","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsandord%2Fikbd4gfa","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsandord%2Fikbd4gfa/lists"}