ARM application development SDK for MNT ZZ9000 graphics and coprocessor card for classic Amiga computers.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

shell.c 1.5KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. /*
  2. * MNT ZZ9000 Amiga Graphics and ARM Coprocessor SDK
  3. * Code example: "shell"
  4. *
  5. * Copyright (C) 2019, Lukas F. Hartmann <lukas@mntre.com>
  6. * MNT Research GmbH, Berlin
  7. * https://mntre.com
  8. *
  9. * More Info: https://mntre.com/zz9000
  10. *
  11. * SPDX-License-Identifier: GPL-3.0-or-later
  12. * GNU General Public License v3.0 or later
  13. *
  14. * https://spdx.org/licenses/GPL-3.0-or-later.html
  15. */
  16. #include <stdlib.h>
  17. #include <unistd.h>
  18. #include "printf/printf.h"
  19. #include "zz9k_env.h"
  20. void __aeabi_idiv0(int r) {
  21. printf("__aeabi_idiv0()!\n");
  22. while (1) {
  23. }
  24. }
  25. void __aeabi_ldiv0(int r) {
  26. printf("__aeabi_idiv0()!\n");
  27. while (1) {
  28. }
  29. }
  30. struct ZZ9K_ENV* _zz9k_env;
  31. void _putchar(char c) {
  32. _zz9k_env->putchar(c);
  33. };
  34. void __attribute__ ((section (".binstart"))) main(struct ZZ9K_ENV* env) {
  35. _zz9k_env = env;
  36. if (!env) {
  37. return;
  38. }
  39. env->set_output_putchar_to_events(1);
  40. env->set_output_events_blocking(1);
  41. uint16_t ser = 0;
  42. char buffer[64];
  43. uint16_t bufp = 0;
  44. while (1) {
  45. uint16_t newser = env->get_event_serial();
  46. if (newser != ser) {
  47. ser = newser;
  48. uint16_t event = env->get_event_code();
  49. if (event<256) {
  50. // character
  51. if (event!='\n') {
  52. buffer[bufp++] = event;
  53. buffer[bufp] = 0;
  54. }
  55. if (bufp>62) bufp=0;
  56. if (event=='\n') {
  57. printf("we got: [%s]\r\n",buffer);
  58. bufp=0;
  59. }
  60. } else {
  61. printf("event: %x\n",event);
  62. }
  63. }
  64. }
  65. }