├── .gitignore ├── .gitlab-ci.yml ├── LICENSE ├── README.md ├── assets ├── NX App Design.pxm ├── NX Logo.sketch ├── characters.png ├── characters.pxm ├── fonts.png ├── fonts.pxm ├── manual │ ├── icon_desktop.png │ ├── icon_mobile.png │ ├── illustration_building.png │ ├── illustration_disk.png │ ├── illustration_hello.png │ ├── illustration_music.png │ ├── illustration_open.png │ ├── illustration_painting.png │ └── illustration_playing.png ├── old │ ├── App Icon.sketch │ ├── background_designer_sketch.pxm │ ├── character_designer_sketch.pxm │ ├── console_pixel.png │ ├── console_pixel.pxm │ ├── logo.png │ ├── logo.pxm │ ├── mobile_app_icon.png │ └── mobile_app_icon.pxm └── overlay.nx ├── core ├── accessories │ ├── disk_drive.c │ └── disk_drive.h ├── boot_intro.c ├── boot_intro.h ├── core.c ├── core.h ├── core_delegate.c ├── core_delegate.h ├── core_stats.c ├── core_stats.h ├── datamanager │ ├── data_manager.c │ └── data_manager.h ├── interpreter │ ├── charsets.c │ ├── charsets.h │ ├── cmd_audio.c │ ├── cmd_audio.h │ ├── cmd_background.c │ ├── cmd_background.h │ ├── cmd_control.c │ ├── cmd_control.h │ ├── cmd_data.c │ ├── cmd_data.h │ ├── cmd_files.c │ ├── cmd_files.h │ ├── cmd_io.c │ ├── cmd_io.h │ ├── cmd_maths.c │ ├── cmd_maths.h │ ├── cmd_memory.c │ ├── cmd_memory.h │ ├── cmd_screen.c │ ├── cmd_screen.h │ ├── cmd_sprites.c │ ├── cmd_sprites.h │ ├── cmd_strings.c │ ├── cmd_strings.h │ ├── cmd_subs.c │ ├── cmd_subs.h │ ├── cmd_text.c │ ├── cmd_text.h │ ├── cmd_variables.c │ ├── cmd_variables.h │ ├── data.c │ ├── data.h │ ├── error.c │ ├── error.h │ ├── interpreter.c │ ├── interpreter.h │ ├── interpreter_config.h │ ├── interpreter_utils.c │ ├── interpreter_utils.h │ ├── labels.c │ ├── labels.h │ ├── rcstring.c │ ├── rcstring.h │ ├── string_utils.c │ ├── string_utils.h │ ├── token.c │ ├── token.h │ ├── tokenizer.c │ ├── tokenizer.h │ ├── value.c │ ├── value.h │ ├── variables.c │ └── variables.h ├── libraries │ ├── audio_lib.c │ ├── audio_lib.h │ ├── default_characters.c │ ├── default_characters.h │ ├── sprites_lib.c │ ├── sprites_lib.h │ ├── startup_sequence.c │ ├── startup_sequence.h │ ├── text_lib.c │ └── text_lib.h ├── machine │ ├── audio_chip.c │ ├── audio_chip.h │ ├── io_chip.h │ ├── machine.c │ ├── machine.h │ ├── video_chip.c │ └── video_chip.h └── overlay │ ├── overlay.c │ ├── overlay.h │ ├── overlay_data.c │ └── overlay_data.h ├── docs ├── license.txt ├── manual-images │ ├── icon_desktop.png │ ├── icon_desktop@2x.png │ ├── icon_mobile.png │ ├── icon_mobile@2x.png │ ├── illustration_building.png │ ├── illustration_building@2x.png │ ├── illustration_disk.png │ ├── illustration_disk@2x.png │ ├── illustration_hello.png │ ├── illustration_hello@2x.png │ ├── illustration_music.png │ ├── illustration_music@2x.png │ ├── illustration_open.png │ ├── illustration_open@2x.png │ ├── illustration_painting.png │ ├── illustration_painting@2x.png │ ├── illustration_playing.png │ └── illustration_playing@2x.png ├── manual.html └── readme.txt ├── extras └── LowRes NX.sublime-syntax ├── libretro ├── libretro.h ├── libretro_main.c └── libretro_main.h ├── platform ├── GameShell │ ├── README.md │ └── home │ │ └── cpi │ │ ├── apps │ │ └── Menu │ │ │ └── 55_LowRes NX │ │ │ ├── LowRes NX.png │ │ │ └── action.config │ │ └── games │ │ └── LowResNX │ │ ├── LowRes Galaxy 2 (1.5).nx │ │ └── Star Scroller 1.2.nx ├── LibRetro │ ├── Makefile │ ├── Makefile.common │ ├── jni │ │ ├── Android.mk │ │ └── Application.mk │ └── link.T ├── Linux │ ├── README.md │ └── makefile ├── Windows │ ├── LowRes NX Win.sln │ ├── LowRes NX Win │ │ ├── LowRes NX Win.rc │ │ ├── LowRes NX Win.vcxproj │ │ ├── LowRes NX Win.vcxproj.filters │ │ ├── icon1.ico │ │ ├── resource.h │ │ └── resource1.h │ └── assets │ │ ├── App Icon 16.png │ │ ├── App Icon 256.png │ │ ├── App Icon 32.png │ │ ├── App Icon 48.png │ │ └── lowresnx.ico ├── iOS │ ├── LowRes NX iOS.xcodeproj │ │ ├── project.pbxproj │ │ └── project.xcworkspace │ │ │ ├── contents.xcworkspacedata │ │ │ └── xcshareddata │ │ │ └── IDEWorkspaceChecks.plist │ ├── LowRes NX iOS │ │ ├── AppDelegate.swift │ │ ├── Assets.xcassets │ │ │ ├── AppIcon.appiconset │ │ │ │ └── Contents.json │ │ │ └── Contents.json │ │ ├── Base.lproj │ │ │ ├── LaunchScreen.storyboard │ │ │ └── Main.storyboard │ │ ├── CoreWrapper.swift │ │ ├── Info.plist │ │ ├── LowResNX-Bridging-Header.h │ │ ├── LowResNXView.swift │ │ └── ViewController.swift │ └── program.nx ├── macOS │ ├── LowRes NX macOS.xcodeproj │ │ ├── project.pbxproj │ │ └── project.xcworkspace │ │ │ ├── contents.xcworkspacedata │ │ │ └── xcshareddata │ │ │ └── IDEWorkspaceChecks.plist │ └── LowRes NX macOS │ │ ├── Assets.xcassets │ │ ├── AppIcon.appiconset │ │ │ ├── Contents.json │ │ │ ├── Mac App Icon 128.png │ │ │ ├── Mac App Icon 16.png │ │ │ ├── Mac App Icon 16@2x.png │ │ │ ├── Mac App Icon 256-1.png │ │ │ ├── Mac App Icon 256.png │ │ │ ├── Mac App Icon 32.png │ │ │ ├── Mac App Icon 512-1.png │ │ │ ├── Mac App Icon 512.png │ │ │ ├── Mac App Icon 512@2x.png │ │ │ └── Mac App Icon 64.png │ │ └── Contents.json │ │ ├── Info.plist │ │ └── LowRes_NX_macOS_SDL.entitlements └── web │ ├── README.md │ ├── embed │ ├── package │ │ ├── LowResNX120.js │ │ ├── LowResNX120.wasm │ │ ├── index.html │ │ └── program.nx │ └── readme.txt │ ├── makefile │ └── output │ ├── LowResNX100.js │ ├── LowResNX100.wasm │ ├── LowResNX110.js │ ├── LowResNX110.wasm │ ├── LowResNX120.js │ └── LowResNX120.wasm ├── programs test ├── BG Scroll.nx ├── Crazy Text.nx ├── Demo 0.5.nx ├── Demo 0.5.png ├── Files.nx ├── Scrolling Map 0.3.nx ├── Scrolling Map 0.3.png ├── Slide Show 0.4.nx ├── Slide Show 0.4.png ├── Sprites with Background 0.3.nx ├── Sprites with Background 0.3.png ├── Subs 1.nx ├── Subs 2.nx ├── drawing.nx ├── gamepad.nx ├── hello world.nx ├── sprite collision.nx └── touch.nx ├── programs ├── Gfx Designer 2.0.nx ├── Gfx Designer 2.0.png ├── LowRes Adventure 1.1.nx ├── LowRes Adventure 1.1.png ├── LowRes Galaxy 2 (1.5).nx ├── LowRes Galaxy 2 (1.5).png ├── Sound Composer 1.5.nx ├── Sound Composer 1.5.png ├── Star Scroller 1.2.nx └── Star Scroller 1.2.png ├── scripts ├── export_characters.py └── export_characters_hex.py └── sdl ├── config.h ├── dev_menu.c ├── dev_menu.h ├── dev_menu_data.h ├── main.c ├── main.h ├── runner.c ├── runner.h ├── screenshot.c ├── screenshot.h ├── sdl_include.h ├── settings.c ├── settings.h ├── stb_image_write.h ├── system_paths.c ├── system_paths.h ├── utils.c └── utils.h /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | # 3 | # gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore 4 | 5 | ## Build generated 6 | build/ 7 | DerivedData/ 8 | 9 | ## Various settings 10 | *.pbxuser 11 | !default.pbxuser 12 | *.mode1v3 13 | !default.mode1v3 14 | *.mode2v3 15 | !default.mode2v3 16 | *.perspectivev3 17 | !default.perspectivev3 18 | xcuserdata/ 19 | 20 | ## Other 21 | *.moved-aside 22 | *.xcuserstate 23 | 24 | ## Obj-C/Swift specific 25 | *.hmap 26 | *.ipa 27 | *.dSYM.zip 28 | *.dSYM 29 | 30 | # CocoaPods 31 | # 32 | # We recommend against adding the Pods directory to your .gitignore. However 33 | # you should judge for yourself, the pros and cons are mentioned at: 34 | # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control 35 | # 36 | # Pods/ 37 | 38 | # Carthage 39 | # 40 | # Add this line if you want to avoid checking in source code from Carthage dependencies. 41 | # Carthage/Checkouts 42 | 43 | Carthage/Build 44 | 45 | # fastlane 46 | # 47 | # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the 48 | # screenshots whenever they are needed. 49 | # For more information about the recommended setup visit: 50 | # https://github.com/fastlane/fastlane/blob/master/fastlane/docs/Gitignore.md 51 | 52 | fastlane/report.xml 53 | fastlane/screenshots 54 | 55 | #Code Injection 56 | # 57 | # After new code Injection tools there's a generated folder /iOSInjectionProject 58 | # https://github.com/johnno1962/injectionforxcode 59 | 60 | iOSInjectionProject/ 61 | platform/Windows/LowRes NX Win/Debug/ 62 | platform/Windows/LowRes NX Win/Release/ 63 | platform/Linux/output/ 64 | platform/Windows/Debug/ 65 | platform/Windows/Release/ 66 | platform/Windows/LowRes NX Win/SDL2.dll 67 | platform/Windows/.vs/ 68 | *.user 69 | *.aps 70 | *.bc 71 | platform/web/output 72 | Disk.nx 73 | *.o 74 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2016-2021 Timo Kloss 2 | 3 | This software is provided 'as-is', without any express or implied 4 | warranty. In no event will the authors be held liable for any damages 5 | arising from the use of this software. 6 | 7 | Permission is granted to anyone to use this software for any purpose, 8 | including commercial applications, and to alter it and redistribute it 9 | freely, subject to the following restrictions: 10 | 11 | 1. The origin of this software must not be misrepresented; you must not 12 | claim that you wrote the original software. If you use this software 13 | in a product, an acknowledgment in the product documentation would be 14 | appreciated but is not required. 15 | 2. Altered source versions must be plainly marked as such, and must not be 16 | misrepresented as being the original software. 17 | 3. This notice may not be removed or altered from any source distribution. 18 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # LowRes NX 2 | 3 | ## Program retro games in BASIC 4 | 5 | Make your own retro games on a virtual game console. Program in the classic BASIC language and create sprites, tile maps, sound and music with the included tools. As a beginner you will quickly understand how to create simple text games or show your first sprite on a tile map. As an experienced programmer you can discover the full potential of retro hardware tricks! 6 | 7 | ## Virtual Game Console 8 | 9 | Imagine LowRes NX as a handheld game console with a d-pad, two action buttons and a little rubber keyboard below a slidable touchscreen. LowRes NX was inspired by real 8- and 16-bit systems and simulates chips for graphics, sound and I/O, which actually work like classic hardware. It supports hardware sprites as well as hardware parallax scrolling, and even offers vertical blank and raster interrupts to create authentic retro effects. 10 | 11 | ## Old-School Programming 12 | 13 | The programming language of LowRes NX is based on second-generation, structured BASIC. It offers all the classic commands, but with labels, loops and subprograms instead of line numbers. Graphics and sound are supported by additional commands and you can even access the virtual hardware directly using PEEK and POKE. You have complete control over the program flow, there is no standard update function to implement. 14 | 15 | ## Creative Tools 16 | 17 | LowRes NX includes all the tools you need: The Gfx Designer for editing sprites, tiles, fonts and maps, as well as the Sound Composer for music and sound effects. All of these are just normal BASIC programs. You can change and improve them or even create your own custom editors. 18 | 19 | ## Share and Play 20 | 21 | Send your games directly to other users or share them via the website. All programs are open source, so you can play them, learn from them and edit them. Do you prefer making just art or music? Share your creations as assets and let other programmers use them in their projects. 22 | -------------------------------------------------------------------------------- /assets/NX App Design.pxm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timoinutilis/lowres-nx/85c80181d26bb5c2147ebc76bfc48bce9f8d73a8/assets/NX App Design.pxm -------------------------------------------------------------------------------- /assets/NX Logo.sketch: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timoinutilis/lowres-nx/85c80181d26bb5c2147ebc76bfc48bce9f8d73a8/assets/NX Logo.sketch -------------------------------------------------------------------------------- /assets/characters.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timoinutilis/lowres-nx/85c80181d26bb5c2147ebc76bfc48bce9f8d73a8/assets/characters.png -------------------------------------------------------------------------------- /assets/characters.pxm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timoinutilis/lowres-nx/85c80181d26bb5c2147ebc76bfc48bce9f8d73a8/assets/characters.pxm -------------------------------------------------------------------------------- /assets/fonts.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timoinutilis/lowres-nx/85c80181d26bb5c2147ebc76bfc48bce9f8d73a8/assets/fonts.png -------------------------------------------------------------------------------- /assets/fonts.pxm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timoinutilis/lowres-nx/85c80181d26bb5c2147ebc76bfc48bce9f8d73a8/assets/fonts.pxm -------------------------------------------------------------------------------- /assets/manual/icon_desktop.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timoinutilis/lowres-nx/85c80181d26bb5c2147ebc76bfc48bce9f8d73a8/assets/manual/icon_desktop.png -------------------------------------------------------------------------------- /assets/manual/icon_mobile.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timoinutilis/lowres-nx/85c80181d26bb5c2147ebc76bfc48bce9f8d73a8/assets/manual/icon_mobile.png -------------------------------------------------------------------------------- /assets/manual/illustration_building.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timoinutilis/lowres-nx/85c80181d26bb5c2147ebc76bfc48bce9f8d73a8/assets/manual/illustration_building.png -------------------------------------------------------------------------------- /assets/manual/illustration_disk.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timoinutilis/lowres-nx/85c80181d26bb5c2147ebc76bfc48bce9f8d73a8/assets/manual/illustration_disk.png -------------------------------------------------------------------------------- /assets/manual/illustration_hello.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timoinutilis/lowres-nx/85c80181d26bb5c2147ebc76bfc48bce9f8d73a8/assets/manual/illustration_hello.png -------------------------------------------------------------------------------- /assets/manual/illustration_music.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timoinutilis/lowres-nx/85c80181d26bb5c2147ebc76bfc48bce9f8d73a8/assets/manual/illustration_music.png -------------------------------------------------------------------------------- /assets/manual/illustration_open.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timoinutilis/lowres-nx/85c80181d26bb5c2147ebc76bfc48bce9f8d73a8/assets/manual/illustration_open.png -------------------------------------------------------------------------------- /assets/manual/illustration_painting.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timoinutilis/lowres-nx/85c80181d26bb5c2147ebc76bfc48bce9f8d73a8/assets/manual/illustration_painting.png -------------------------------------------------------------------------------- /assets/manual/illustration_playing.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timoinutilis/lowres-nx/85c80181d26bb5c2147ebc76bfc48bce9f8d73a8/assets/manual/illustration_playing.png -------------------------------------------------------------------------------- /assets/old/App Icon.sketch: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timoinutilis/lowres-nx/85c80181d26bb5c2147ebc76bfc48bce9f8d73a8/assets/old/App Icon.sketch -------------------------------------------------------------------------------- /assets/old/background_designer_sketch.pxm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timoinutilis/lowres-nx/85c80181d26bb5c2147ebc76bfc48bce9f8d73a8/assets/old/background_designer_sketch.pxm -------------------------------------------------------------------------------- /assets/old/character_designer_sketch.pxm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timoinutilis/lowres-nx/85c80181d26bb5c2147ebc76bfc48bce9f8d73a8/assets/old/character_designer_sketch.pxm -------------------------------------------------------------------------------- /assets/old/console_pixel.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timoinutilis/lowres-nx/85c80181d26bb5c2147ebc76bfc48bce9f8d73a8/assets/old/console_pixel.png -------------------------------------------------------------------------------- /assets/old/console_pixel.pxm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timoinutilis/lowres-nx/85c80181d26bb5c2147ebc76bfc48bce9f8d73a8/assets/old/console_pixel.pxm -------------------------------------------------------------------------------- /assets/old/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timoinutilis/lowres-nx/85c80181d26bb5c2147ebc76bfc48bce9f8d73a8/assets/old/logo.png -------------------------------------------------------------------------------- /assets/old/logo.pxm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timoinutilis/lowres-nx/85c80181d26bb5c2147ebc76bfc48bce9f8d73a8/assets/old/logo.pxm -------------------------------------------------------------------------------- /assets/old/mobile_app_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timoinutilis/lowres-nx/85c80181d26bb5c2147ebc76bfc48bce9f8d73a8/assets/old/mobile_app_icon.png -------------------------------------------------------------------------------- /assets/old/mobile_app_icon.pxm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timoinutilis/lowres-nx/85c80181d26bb5c2147ebc76bfc48bce9f8d73a8/assets/old/mobile_app_icon.pxm -------------------------------------------------------------------------------- /assets/overlay.nx: -------------------------------------------------------------------------------- 1 | #2:CHARS 2 | 00000000000000000000000000000000 3 | 3C3C3C3C3C3C3C3C3C242424243C243C 4 | FEFEFEFE7E000000FE9292DA7E000000 5 | 7EFFFFFFFFFFFF7E7EDB81DBDB81DB7E 6 | 1C7F7F7F7F7F7F1C1C7741477141771C 7 | F7FFFFFE7FFFFFEFF79D9BF66FD9B9EF 8 | 3E7E7EFFFFFFFF7F3E624AC7919BC57F 9 | 3C3C7C7C780000003C24644C78000000 10 | 1E3E7E7C7C7E3E1E1E32664C4C66321E 11 | 787C7E3E3E7E7C78784C663232664C78 12 | 007E7EFFFFFF7E7E007E5AE781E75A7E 13 | 003C3CFFFFFF3C3C003C24E781E7243C 14 | 0000003C3C7C7C780000003C24644C78 15 | 000000FFFFFF0000000000FF81FF0000 16 | 000000003C3C3C3C000000003C24243C 17 | 0F1F3F7EFCF8F0E00F193366CC98B0E0 18 | 7EFFFFFFFFFFFF7E7EC399918999C37E 19 | 3C7C7C7C3CFFFFFF3C64446424E781FF 20 | 7EFFFFFF7EFFFFFF7EC399F366CF81FF 21 | 7EFFFFFFFFFFFF7E7EC399F3F999C37E 22 | FFFFFFFFFF0F0F0FFF999981F909090F 23 | FFFFFFFFFFFFFFFEFF819F83F9F983FE 24 | 3E7EFEFFFFFFFF7E3E62CE839999C37E 25 | FFFFFF3F7E7C7878FF81F933664C4878 26 | 7EFFFFFFFFFFFF7E7EC399C39999C37E 27 | 7EFFFFFFFFFFFF7E7EC399C1F999C37E 28 | 00003C3C3C3C3C0000003C243C243C00 29 | 00003C3C3C7C7C7800003C243C644C78 30 | 001E3E7E7C7E3E1E001E32664C66321E 31 | 0000FFFFFFFFFF000000FF81FF81FF00 32 | 00787C7E3E7E7C7800784C6632664C78 33 | 7EFFFFFF3E3C3C3C7EC399F3263C243C 34 | 7EFFFFFFFFFFFE7E7EC39991919FC27E 35 | 3C7EFFFFFFFFFFFF3C66C399819999FF 36 | FEFFFFFFFFFFFFFEFE839983999983FE 37 | 7EFFFFFFFFFFFF7E7EC3999F9F99C37E 38 | FCFEFFFFFFFFFEFCFC869399999386FC 39 | FFFFFFFCFCFFFFFFFF819F849C9F81FF 40 | FFFFFFFCFCF0F0F0FF819F849C9090F0 41 | 7EFEFFFFFFFFFF7E7EC29F919999C37E 42 | FFFFFFFFFFFFFFFFFF999981999999FF 43 | 7E7E7E3C3C7E7E7E7E4266242466427E 44 | 3F3F3F0FFFFFFF7E3F213909F999C37E 45 | FFFFFFFEFEFFFFFFFF999386869399FF 46 | F0F0F0F0F0FFFFFFF0909090909F81FF 47 | E7FFFFFFFFFFFFFFE7BD9981819999FF 48 | FFFFFFFFFFFFFFFFFF998981919999FF 49 | 7EFFFFFFFFFFFF7E7EC399999999C37E 50 | FEFFFFFFFEF0F0F0FE8399839E9090F0 51 | 7EFFFFFFFFFFFF7F7EC399999593C17F 52 | FEFFFFFFFEFFFFFFFE839983869399FF 53 | 7FFFFFFF7FFFFFFE7FC19FC379F983FE 54 | FFFFFF3C3C3C3C3CFF81E7242424243C 55 | FFFFFFFFFFFFFF7EFF9999999999C37E 56 | FFFFFFFFFFFF7E3CFF99999999C3663C 57 | FFFFFFFFFFFFFFE7FF9999818199BDE7 58 | FFFFFF7EFFFFFFFFFF99C366C39999FF 59 | FFFFFFFF7E3C3C3CFF9999C36624243C 60 | FFFFFF7EFCFFFFFFFF81F366CC9F81FF 61 | 7EFFFFFFFFFFFF7E7EC399A5BDA5C37E 62 | 7EFFFFFFFFFFFF7E7EC3A1B9A5B9C37E 63 | 3C7EFFFFFFFF7E3C3C66E78181E7663C 64 | 3C7EFFFFFF0000003C66C399FF000000 65 | 0000000000FFFFFF0000000000FF81FF 66 | 67 | -------------------------------------------------------------------------------- /core/accessories/disk_drive.c: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright 2017 Timo Kloss 3 | // 4 | // This software is provided 'as-is', without any express or implied 5 | // warranty. In no event will the authors be held liable for any damages 6 | // arising from the use of this software. 7 | // 8 | // Permission is granted to anyone to use this software for any purpose, 9 | // including commercial applications, and to alter it and redistribute it 10 | // freely, subject to the following restrictions: 11 | // 12 | // 1. The origin of this software must not be misrepresented; you must not 13 | // claim that you wrote the original software. If you use this software 14 | // in a product, an acknowledgment in the product documentation would be 15 | // appreciated but is not required. 16 | // 2. Altered source versions must be plainly marked as such, and must not be 17 | // misrepresented as being the original software. 18 | // 3. This notice may not be removed or altered from any source distribution. 19 | // 20 | 21 | #include "disk_drive.h" 22 | #include "core.h" 23 | #include 24 | #include 25 | #include 26 | #include 27 | 28 | void disk_init(struct Core *core) 29 | { 30 | // init lazily in disk_prepare() 31 | } 32 | 33 | void disk_deinit(struct Core *core) 34 | { 35 | struct DataManager *dataManager = &core->diskDrive->dataManager; 36 | if (dataManager->data) 37 | { 38 | free(dataManager->data); 39 | dataManager->data = NULL; 40 | } 41 | data_deinit(dataManager); 42 | } 43 | 44 | void disk_reset(struct Core *core) 45 | { 46 | struct DataManager *dataManager = &core->diskDrive->dataManager; 47 | if (dataManager->data) 48 | { 49 | data_reset(dataManager); 50 | } 51 | } 52 | 53 | bool disk_prepare(struct Core *core) 54 | { 55 | struct DataManager *dataManager = &core->diskDrive->dataManager; 56 | if (dataManager->data == NULL) 57 | { 58 | dataManager->data = calloc(DATA_SIZE, 1); 59 | if (!dataManager->data) exit(EXIT_FAILURE); 60 | 61 | data_init(dataManager); 62 | } 63 | return delegate_diskDriveWillAccess(core); 64 | } 65 | 66 | bool disk_saveFile(struct Core *core, int index, char *comment, int address, int length) 67 | { 68 | if (!disk_prepare(core)) 69 | { 70 | return false; 71 | } 72 | 73 | assert(address >= 0 && address + length <= sizeof(struct Machine)); 74 | struct DataManager *dataManager = &core->diskDrive->dataManager; 75 | if (!data_canSetEntry(dataManager, index, length)) 76 | { 77 | delegate_diskDriveIsFull(core); 78 | } 79 | else 80 | { 81 | uint8_t *source = &((uint8_t *)core->machine)[address]; 82 | data_setEntry(dataManager, index, comment, source, length); 83 | 84 | delegate_diskDriveDidSave(core); 85 | } 86 | return true; 87 | } 88 | 89 | bool disk_loadFile(struct Core *core, int index, int address, int maxLength, int offset, bool *pokeFailed) 90 | { 91 | if (!disk_prepare(core)) 92 | { 93 | return false; 94 | } 95 | 96 | struct DataEntry *entry = &core->diskDrive->dataManager.entries[index]; 97 | uint8_t *data = core->diskDrive->dataManager.data; 98 | 99 | // read file 100 | int start = entry->start + offset; 101 | int length = entry->length; 102 | if (maxLength > 0 && length > maxLength) 103 | { 104 | length = maxLength; 105 | } 106 | if (offset + length > entry->length) 107 | { 108 | length = entry->length - offset; 109 | } 110 | for (int i = 0; i < length; i++) 111 | { 112 | bool poke = machine_poke(core, address + i, data[i + start]); 113 | if (!poke) 114 | { 115 | *pokeFailed = true; 116 | return true; 117 | } 118 | } 119 | return true; 120 | } 121 | -------------------------------------------------------------------------------- /core/accessories/disk_drive.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright 2017 Timo Kloss 3 | // 4 | // This software is provided 'as-is', without any express or implied 5 | // warranty. In no event will the authors be held liable for any damages 6 | // arising from the use of this software. 7 | // 8 | // Permission is granted to anyone to use this software for any purpose, 9 | // including commercial applications, and to alter it and redistribute it 10 | // freely, subject to the following restrictions: 11 | // 12 | // 1. The origin of this software must not be misrepresented; you must not 13 | // claim that you wrote the original software. If you use this software 14 | // in a product, an acknowledgment in the product documentation would be 15 | // appreciated but is not required. 16 | // 2. Altered source versions must be plainly marked as such, and must not be 17 | // misrepresented as being the original software. 18 | // 3. This notice may not be removed or altered from any source distribution. 19 | // 20 | 21 | #ifndef disk_drive_h 22 | #define disk_drive_h 23 | 24 | #include 25 | #include 26 | #include "data_manager.h" 27 | 28 | struct Core; 29 | 30 | struct DiskDrive { 31 | struct DataManager dataManager; 32 | }; 33 | 34 | void disk_init(struct Core *core); 35 | void disk_deinit(struct Core *core); 36 | void disk_reset(struct Core *core); 37 | 38 | bool disk_prepare(struct Core *core); 39 | bool disk_saveFile(struct Core *core, int index, char *comment, int address, int length); 40 | bool disk_loadFile(struct Core *core, int index, int address, int maxLength, int offset, bool *pokeFailed); 41 | 42 | #endif /* disk_drive_h */ 43 | -------------------------------------------------------------------------------- /core/boot_intro.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright 2017-2018 Timo Kloss 3 | // 4 | // This software is provided 'as-is', without any express or implied 5 | // warranty. In no event will the authors be held liable for any damages 6 | // arising from the use of this software. 7 | // 8 | // Permission is granted to anyone to use this software for any purpose, 9 | // including commercial applications, and to alter it and redistribute it 10 | // freely, subject to the following restrictions: 11 | // 12 | // 1. The origin of this software must not be misrepresented; you must not 13 | // claim that you wrote the original software. If you use this software 14 | // in a product, an acknowledgment in the product documentation would be 15 | // appreciated but is not required. 16 | // 2. Altered source versions must be plainly marked as such, and must not be 17 | // misrepresented as being the original software. 18 | // 3. This notice may not be removed or altered from any source distribution. 19 | // 20 | 21 | #ifndef boot_intro_h 22 | #define boot_intro_h 23 | 24 | extern const int bootIntroStateAddress; 25 | extern const char *bootIntroSourceCode; 26 | 27 | enum BootIntroState { 28 | BootIntroStateDefault, 29 | BootIntroStateProgramAvailable, 30 | BootIntroStateReadyToRun, 31 | BootIntroStateDone 32 | }; 33 | 34 | #endif /* boot_intro_h */ 35 | -------------------------------------------------------------------------------- /core/core.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright 2016-2020 Timo Kloss 3 | // 4 | // This software is provided 'as-is', without any express or implied 5 | // warranty. In no event will the authors be held liable for any damages 6 | // arising from the use of this software. 7 | // 8 | // Permission is granted to anyone to use this software for any purpose, 9 | // including commercial applications, and to alter it and redistribute it 10 | // freely, subject to the following restrictions: 11 | // 12 | // 1. The origin of this software must not be misrepresented; you must not 13 | // claim that you wrote the original software. If you use this software 14 | // in a product, an acknowledgment in the product documentation would be 15 | // appreciated but is not required. 16 | // 2. Altered source versions must be plainly marked as such, and must not be 17 | // misrepresented as being the original software. 18 | // 3. This notice may not be removed or altered from any source distribution. 19 | // 20 | 21 | #ifndef core_h 22 | #define core_h 23 | 24 | #define CORE_VERSION "1.2" 25 | 26 | #include 27 | #include 28 | #include "machine.h" 29 | #include "overlay.h" 30 | #include "interpreter.h" 31 | #include "disk_drive.h" 32 | #include "core_delegate.h" 33 | 34 | struct Core { 35 | struct Machine *machine; 36 | struct MachineInternals *machineInternals; 37 | struct Interpreter *interpreter; 38 | struct DiskDrive *diskDrive; 39 | struct Overlay *overlay; 40 | struct CoreDelegate *delegate; 41 | }; 42 | 43 | struct CoreInputGamepad { 44 | bool up; 45 | bool down; 46 | bool left; 47 | bool right; 48 | bool buttonA; 49 | bool buttonB; 50 | }; 51 | 52 | struct CoreInput { 53 | struct CoreInputGamepad gamepads[NUM_GAMEPADS]; 54 | bool pause; 55 | int touchX; 56 | int touchY; 57 | bool touch; 58 | char key; 59 | bool out_hasUsedInput; 60 | }; 61 | 62 | extern const char CoreInputKeyReturn; 63 | extern const char CoreInputKeyBackspace; 64 | extern const char CoreInputKeyRight; 65 | extern const char CoreInputKeyLeft; 66 | extern const char CoreInputKeyDown; 67 | extern const char CoreInputKeyUp; 68 | 69 | void core_init(struct Core *core); 70 | void core_deinit(struct Core *core); 71 | void core_setDelegate(struct Core *core, struct CoreDelegate *delegate); 72 | struct CoreError core_compileProgram(struct Core *core, const char *sourceCode, bool resetPersistent); 73 | void core_traceError(struct Core *core, struct CoreError error); 74 | void core_willRunProgram(struct Core *core, long secondsSincePowerOn); 75 | void core_update(struct Core *core, struct CoreInput *input); 76 | void core_willSuspendProgram(struct Core *core); 77 | void core_setDebug(struct Core *core, bool enabled); 78 | bool core_getDebug(struct Core *core); 79 | bool core_isKeyboardEnabled(struct Core *core); 80 | bool core_shouldRender(struct Core *core); 81 | 82 | void core_setInputGamepad(struct CoreInput *input, int player, bool up, bool down, bool left, bool right, bool buttonA, bool buttonB); 83 | 84 | void core_diskLoaded(struct Core *core); 85 | 86 | // for dev mode only: 87 | void core_handleInput(struct Core *core, struct CoreInput *input); 88 | 89 | #endif /* core_h */ 90 | -------------------------------------------------------------------------------- /core/core_delegate.c: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright 2017 Timo Kloss 3 | // 4 | // This software is provided 'as-is', without any express or implied 5 | // warranty. In no event will the authors be held liable for any damages 6 | // arising from the use of this software. 7 | // 8 | // Permission is granted to anyone to use this software for any purpose, 9 | // including commercial applications, and to alter it and redistribute it 10 | // freely, subject to the following restrictions: 11 | // 12 | // 1. The origin of this software must not be misrepresented; you must not 13 | // claim that you wrote the original software. If you use this software 14 | // in a product, an acknowledgment in the product documentation would be 15 | // appreciated but is not required. 16 | // 2. Altered source versions must be plainly marked as such, and must not be 17 | // misrepresented as being the original software. 18 | // 3. This notice may not be removed or altered from any source distribution. 19 | // 20 | 21 | #include 22 | #include "core.h" 23 | 24 | void delegate_interpreterDidFail(struct Core *core, struct CoreError coreError) 25 | { 26 | if (core->delegate->interpreterDidFail) 27 | { 28 | core->delegate->interpreterDidFail(core->delegate->context, coreError); 29 | } 30 | } 31 | 32 | bool delegate_diskDriveWillAccess(struct Core *core) 33 | { 34 | if (core->delegate->diskDriveWillAccess) 35 | { 36 | return core->delegate->diskDriveWillAccess(core->delegate->context, &core->diskDrive->dataManager); 37 | } 38 | return true; 39 | } 40 | 41 | void delegate_diskDriveDidSave(struct Core *core) 42 | { 43 | if (core->delegate->diskDriveDidSave) 44 | { 45 | core->delegate->diskDriveDidSave(core->delegate->context, &core->diskDrive->dataManager); 46 | } 47 | } 48 | 49 | void delegate_diskDriveIsFull(struct Core *core) 50 | { 51 | if (core->delegate->diskDriveIsFull) 52 | { 53 | core->delegate->diskDriveIsFull(core->delegate->context, &core->diskDrive->dataManager); 54 | } 55 | } 56 | 57 | void delegate_controlsDidChange(struct Core *core) 58 | { 59 | if (core->delegate->controlsDidChange) 60 | { 61 | struct ControlsInfo info; 62 | union IOAttributes ioAttr = core->machine->ioRegisters.attr; 63 | if (ioAttr.keyboardEnabled) 64 | { 65 | if (core->interpreter->isKeyboardOptional) 66 | { 67 | info.keyboardMode = KeyboardModeOptional; 68 | } 69 | else 70 | { 71 | info.keyboardMode = KeyboardModeOn; 72 | } 73 | } 74 | else 75 | { 76 | info.keyboardMode = KeyboardModeOff; 77 | } 78 | info.numGamepadsEnabled = ioAttr.keyboardEnabled ? 0 : ioAttr.gamepadsEnabled; 79 | info.isTouchEnabled = ioAttr.touchEnabled; 80 | info.isAudioEnabled = core->machineInternals->audioInternals.audioEnabled; 81 | core->delegate->controlsDidChange(core->delegate->context, info); 82 | } 83 | } 84 | 85 | void delegate_persistentRamWillAccess(struct Core *core, uint8_t *destination, int size) 86 | { 87 | if (core->delegate->persistentRamWillAccess) 88 | { 89 | core->delegate->persistentRamWillAccess(core->delegate->context, destination, size); 90 | } 91 | } 92 | 93 | void delegate_persistentRamDidChange(struct Core *core, uint8_t *data, int size) 94 | { 95 | if (core->delegate->persistentRamDidChange) 96 | { 97 | core->delegate->persistentRamDidChange(core->delegate->context, data, size); 98 | } 99 | } 100 | -------------------------------------------------------------------------------- /core/core_delegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright 2017 Timo Kloss 3 | // 4 | // This software is provided 'as-is', without any express or implied 5 | // warranty. In no event will the authors be held liable for any damages 6 | // arising from the use of this software. 7 | // 8 | // Permission is granted to anyone to use this software for any purpose, 9 | // including commercial applications, and to alter it and redistribute it 10 | // freely, subject to the following restrictions: 11 | // 12 | // 1. The origin of this software must not be misrepresented; you must not 13 | // claim that you wrote the original software. If you use this software 14 | // in a product, an acknowledgment in the product documentation would be 15 | // appreciated but is not required. 16 | // 2. Altered source versions must be plainly marked as such, and must not be 17 | // misrepresented as being the original software. 18 | // 3. This notice may not be removed or altered from any source distribution. 19 | // 20 | 21 | #ifndef core_delegate_h 22 | #define core_delegate_h 23 | 24 | #include "data_manager.h" 25 | #include "error.h" 26 | 27 | struct Core; 28 | 29 | enum KeyboardMode { 30 | KeyboardModeOff, 31 | KeyboardModeOn, 32 | KeyboardModeOptional 33 | }; 34 | 35 | struct ControlsInfo { 36 | enum KeyboardMode keyboardMode; 37 | int numGamepadsEnabled; 38 | bool isTouchEnabled; 39 | bool isAudioEnabled; 40 | }; 41 | 42 | struct CoreDelegate { 43 | void *context; 44 | 45 | /** Called on error */ 46 | void (*interpreterDidFail)(void *context, struct CoreError coreError); 47 | 48 | /** Returns true if the disk is ready, false if not. In case of not, core_diskLoaded must be called when ready. */ 49 | bool (*diskDriveWillAccess)(void *context, struct DataManager *diskDataManager); 50 | 51 | /** Called when a disk data entry was saved */ 52 | void (*diskDriveDidSave)(void *context, struct DataManager *diskDataManager); 53 | 54 | /** Called when a disk data entry was tried to be saved, but the disk is full */ 55 | void (*diskDriveIsFull)(void *context, struct DataManager *diskDataManager); 56 | 57 | /** Called when keyboard or gamepad settings changed */ 58 | void (*controlsDidChange)(void *context, struct ControlsInfo controlsInfo); 59 | 60 | /** Called when persistent RAM will be accessed the first time */ 61 | void (*persistentRamWillAccess)(void *context, uint8_t *destination, int size); 62 | 63 | /** Called when persistent RAM should be saved */ 64 | void (*persistentRamDidChange)(void *context, uint8_t *data, int size); 65 | }; 66 | 67 | void delegate_interpreterDidFail(struct Core *core, struct CoreError coreError); 68 | bool delegate_diskDriveWillAccess(struct Core *core); 69 | void delegate_diskDriveDidSave(struct Core *core); 70 | void delegate_diskDriveIsFull(struct Core *core); 71 | void delegate_controlsDidChange(struct Core *core); 72 | void delegate_persistentRamWillAccess(struct Core *core, uint8_t *destination, int size); 73 | void delegate_persistentRamDidChange(struct Core *core, uint8_t *data, int size); 74 | 75 | #endif /* core_delegate_h */ 76 | -------------------------------------------------------------------------------- /core/core_stats.c: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright 2020 Timo Kloss 3 | // 4 | // This software is provided 'as-is', without any express or implied 5 | // warranty. In no event will the authors be held liable for any damages 6 | // arising from the use of this software. 7 | // 8 | // Permission is granted to anyone to use this software for any purpose, 9 | // including commercial applications, and to alter it and redistribute it 10 | // freely, subject to the following restrictions: 11 | // 12 | // 1. The origin of this software must not be misrepresented; you must not 13 | // claim that you wrote the original software. If you use this software 14 | // in a product, an acknowledgment in the product documentation would be 15 | // appreciated but is not required. 16 | // 2. Altered source versions must be plainly marked as such, and must not be 17 | // misrepresented as being the original software. 18 | // 3. This notice may not be removed or altered from any source distribution. 19 | // 20 | 21 | #include "core_stats.h" 22 | #include 23 | #include 24 | #include "string_utils.h" 25 | 26 | void stats_init(struct Stats *stats) 27 | { 28 | memset(stats, 0, sizeof(struct Stats)); 29 | 30 | stats->tokenizer = calloc(1, sizeof(struct Tokenizer)); 31 | if (!stats->tokenizer) exit(EXIT_FAILURE); 32 | 33 | stats->romDataManager = calloc(1, sizeof(struct DataManager)); 34 | if (!stats->romDataManager) exit(EXIT_FAILURE); 35 | 36 | stats->romDataManager->data = calloc(1, DATA_SIZE); 37 | if (!stats->romDataManager->data) exit(EXIT_FAILURE); 38 | } 39 | 40 | void stats_deinit(struct Stats *stats) 41 | { 42 | free(stats->romDataManager->data); 43 | stats->romDataManager->data = NULL; 44 | 45 | free(stats->tokenizer); 46 | stats->tokenizer = NULL; 47 | 48 | free(stats->romDataManager); 49 | stats->romDataManager = NULL; 50 | } 51 | 52 | struct CoreError stats_update(struct Stats *stats, const char *sourceCode) 53 | { 54 | stats->numTokens = 0; 55 | stats->romSize = 0; 56 | 57 | struct CoreError error = err_noCoreError(); 58 | 59 | const char *upperCaseSourceCode = uppercaseString(sourceCode); 60 | if (!upperCaseSourceCode) 61 | { 62 | error = err_makeCoreError(ErrorOutOfMemory, -1); 63 | goto cleanup; 64 | } 65 | 66 | error = tok_tokenizeUppercaseProgram(stats->tokenizer, upperCaseSourceCode); 67 | if (error.code != ErrorNone) 68 | { 69 | goto cleanup; 70 | } 71 | 72 | stats->numTokens = stats->tokenizer->numTokens; 73 | 74 | struct DataManager *romDataManager = stats->romDataManager; 75 | error = data_uppercaseImport(romDataManager, upperCaseSourceCode, false); 76 | if (error.code != ErrorNone) 77 | { 78 | goto cleanup; 79 | } 80 | 81 | stats->romSize = data_currentSize(stats->romDataManager); 82 | 83 | // add default characters if ROM entry 0 is unused 84 | struct DataEntry *entry0 = &romDataManager->entries[0]; 85 | if (entry0->length == 0 && (DATA_SIZE - data_currentSize(romDataManager)) >= 1024) 86 | { 87 | stats->romSize += 1024; 88 | } 89 | 90 | cleanup: 91 | tok_freeTokens(stats->tokenizer); 92 | if (upperCaseSourceCode) 93 | { 94 | free((void *)upperCaseSourceCode); 95 | } 96 | 97 | return error; 98 | } 99 | -------------------------------------------------------------------------------- /core/core_stats.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright 2020 Timo Kloss 3 | // 4 | // This software is provided 'as-is', without any express or implied 5 | // warranty. In no event will the authors be held liable for any damages 6 | // arising from the use of this software. 7 | // 8 | // Permission is granted to anyone to use this software for any purpose, 9 | // including commercial applications, and to alter it and redistribute it 10 | // freely, subject to the following restrictions: 11 | // 12 | // 1. The origin of this software must not be misrepresented; you must not 13 | // claim that you wrote the original software. If you use this software 14 | // in a product, an acknowledgment in the product documentation would be 15 | // appreciated but is not required. 16 | // 2. Altered source versions must be plainly marked as such, and must not be 17 | // misrepresented as being the original software. 18 | // 3. This notice may not be removed or altered from any source distribution. 19 | // 20 | 21 | #ifndef core_stats_h 22 | #define core_stats_h 23 | 24 | #include 25 | #include "error.h" 26 | #include "tokenizer.h" 27 | #include "data_manager.h" 28 | 29 | struct Stats { 30 | struct Tokenizer *tokenizer; 31 | struct DataManager *romDataManager; 32 | int numTokens; 33 | int romSize; 34 | }; 35 | 36 | void stats_init(struct Stats *stats); 37 | void stats_deinit(struct Stats *stats); 38 | struct CoreError stats_update(struct Stats *stats, const char *sourceCode); 39 | 40 | #endif /* core_stats_h */ 41 | -------------------------------------------------------------------------------- /core/datamanager/data_manager.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright 2017 Timo Kloss 3 | // 4 | // This software is provided 'as-is', without any express or implied 5 | // warranty. In no event will the authors be held liable for any damages 6 | // arising from the use of this software. 7 | // 8 | // Permission is granted to anyone to use this software for any purpose, 9 | // including commercial applications, and to alter it and redistribute it 10 | // freely, subject to the following restrictions: 11 | // 12 | // 1. The origin of this software must not be misrepresented; you must not 13 | // claim that you wrote the original software. If you use this software 14 | // in a product, an acknowledgment in the product documentation would be 15 | // appreciated but is not required. 16 | // 2. Altered source versions must be plainly marked as such, and must not be 17 | // misrepresented as being the original software. 18 | // 3. This notice may not be removed or altered from any source distribution. 19 | // 20 | 21 | #ifndef data_manager_h 22 | #define data_manager_h 23 | 24 | #include 25 | #include 26 | #include 27 | #include "error.h" 28 | 29 | #define MAX_ENTRIES 16 30 | #define DATA_SIZE 0x8000 31 | #define ENTRY_COMMENT_SIZE 32 32 | 33 | struct DataEntry { 34 | char comment[ENTRY_COMMENT_SIZE]; 35 | int start; 36 | int length; 37 | }; 38 | 39 | struct DataManager { 40 | struct DataEntry entries[MAX_ENTRIES]; 41 | uint8_t *data; 42 | const char *diskSourceCode; 43 | }; 44 | 45 | void data_init(struct DataManager *manager); 46 | void data_deinit(struct DataManager *manager); 47 | void data_reset(struct DataManager *manager); 48 | struct CoreError data_import(struct DataManager *manager, const char *input, bool keepSourceCode); 49 | struct CoreError data_uppercaseImport(struct DataManager *manager, const char *input, bool keepSourceCode); 50 | char *data_export(struct DataManager *manager); 51 | 52 | int data_currentSize(struct DataManager *manager); 53 | 54 | bool data_canSetEntry(struct DataManager *manager, int index, int length); 55 | void data_setEntry(struct DataManager *manager, int index, const char *comment, uint8_t *source, int length); 56 | 57 | #endif /* data_manager_h */ 58 | -------------------------------------------------------------------------------- /core/interpreter/charsets.c: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright 2017 Timo Kloss 3 | // 4 | // This software is provided 'as-is', without any express or implied 5 | // warranty. In no event will the authors be held liable for any damages 6 | // arising from the use of this software. 7 | // 8 | // Permission is granted to anyone to use this software for any purpose, 9 | // including commercial applications, and to alter it and redistribute it 10 | // freely, subject to the following restrictions: 11 | // 12 | // 1. The origin of this software must not be misrepresented; you must not 13 | // claim that you wrote the original software. If you use this software 14 | // in a product, an acknowledgment in the product documentation would be 15 | // appreciated but is not required. 16 | // 2. Altered source versions must be plainly marked as such, and must not be 17 | // misrepresented as being the original software. 18 | // 3. This notice may not be removed or altered from any source distribution. 19 | // 20 | 21 | #include "charsets.h" 22 | 23 | const char *CharSetDigits = "0123456789"; 24 | const char *CharSetLetters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ_"; 25 | const char *CharSetAlphaNum = "ABCDEFGHIJKLMNOPQRSTUVWXYZ_0123456789"; 26 | const char *CharSetHex = "0123456789ABCDEF"; 27 | -------------------------------------------------------------------------------- /core/interpreter/charsets.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright 2017 Timo Kloss 3 | // 4 | // This software is provided 'as-is', without any express or implied 5 | // warranty. In no event will the authors be held liable for any damages 6 | // arising from the use of this software. 7 | // 8 | // Permission is granted to anyone to use this software for any purpose, 9 | // including commercial applications, and to alter it and redistribute it 10 | // freely, subject to the following restrictions: 11 | // 12 | // 1. The origin of this software must not be misrepresented; you must not 13 | // claim that you wrote the original software. If you use this software 14 | // in a product, an acknowledgment in the product documentation would be 15 | // appreciated but is not required. 16 | // 2. Altered source versions must be plainly marked as such, and must not be 17 | // misrepresented as being the original software. 18 | // 3. This notice may not be removed or altered from any source distribution. 19 | // 20 | 21 | #ifndef charsets_h 22 | #define charsets_h 23 | 24 | extern const char *CharSetDigits; 25 | extern const char *CharSetLetters; 26 | extern const char *CharSetAlphaNum; 27 | extern const char *CharSetHex; 28 | 29 | #endif /* charsets_h */ 30 | -------------------------------------------------------------------------------- /core/interpreter/cmd_audio.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright 2018 Timo Kloss 3 | // 4 | // This software is provided 'as-is', without any express or implied 5 | // warranty. In no event will the authors be held liable for any damages 6 | // arising from the use of this software. 7 | // 8 | // Permission is granted to anyone to use this software for any purpose, 9 | // including commercial applications, and to alter it and redistribute it 10 | // freely, subject to the following restrictions: 11 | // 12 | // 1. The origin of this software must not be misrepresented; you must not 13 | // claim that you wrote the original software. If you use this software 14 | // in a product, an acknowledgment in the product documentation would be 15 | // appreciated but is not required. 16 | // 2. Altered source versions must be plainly marked as such, and must not be 17 | // misrepresented as being the original software. 18 | // 3. This notice may not be removed or altered from any source distribution. 19 | // 20 | 21 | #ifndef cmd_audio_h 22 | #define cmd_audio_h 23 | 24 | #include 25 | #include "error.h" 26 | #include "value.h" 27 | 28 | struct Core; 29 | 30 | enum ErrorCode cmd_SOUND(struct Core *core); 31 | //enum ErrorCode cmd_SOUND_COPY(struct Core *core); 32 | enum ErrorCode cmd_VOLUME(struct Core *core); 33 | enum ErrorCode cmd_ENVELOPE(struct Core *core); 34 | enum ErrorCode cmd_LFO(struct Core *core); 35 | enum ErrorCode cmd_LFO_A(struct Core *core); 36 | enum ErrorCode cmd_LFO_WAVE(struct Core *core); 37 | enum ErrorCode cmd_PLAY(struct Core *core); 38 | enum ErrorCode cmd_STOP(struct Core *core); 39 | enum ErrorCode cmd_MUSIC(struct Core *core); 40 | enum ErrorCode cmd_TRACK(struct Core *core); 41 | enum ErrorCode cmd_SOUND_SOURCE(struct Core *core); 42 | struct TypedValue fnc_MUSIC(struct Core *core); 43 | 44 | #endif /* cmd_audio_h */ 45 | -------------------------------------------------------------------------------- /core/interpreter/cmd_background.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright 2017-2019 Timo Kloss 3 | // 4 | // This software is provided 'as-is', without any express or implied 5 | // warranty. In no event will the authors be held liable for any damages 6 | // arising from the use of this software. 7 | // 8 | // Permission is granted to anyone to use this software for any purpose, 9 | // including commercial applications, and to alter it and redistribute it 10 | // freely, subject to the following restrictions: 11 | // 12 | // 1. The origin of this software must not be misrepresented; you must not 13 | // claim that you wrote the original software. If you use this software 14 | // in a product, an acknowledgment in the product documentation would be 15 | // appreciated but is not required. 16 | // 2. Altered source versions must be plainly marked as such, and must not be 17 | // misrepresented as being the original software. 18 | // 3. This notice may not be removed or altered from any source distribution. 19 | // 20 | 21 | #ifndef cmd_background_h 22 | #define cmd_background_h 23 | 24 | #include 25 | #include "error.h" 26 | #include "value.h" 27 | 28 | struct Core; 29 | 30 | enum ErrorCode cmd_BG(struct Core *core); 31 | enum ErrorCode cmd_BG_SOURCE(struct Core *core); 32 | enum ErrorCode cmd_BG_COPY(struct Core *core); 33 | enum ErrorCode cmd_BG_SCROLL(struct Core *core); 34 | enum ErrorCode cmd_ATTR(struct Core *core); 35 | enum ErrorCode cmd_PAL(struct Core *core); 36 | enum ErrorCode cmd_FLIP(struct Core *core); 37 | enum ErrorCode cmd_PRIO(struct Core *core); 38 | enum ErrorCode cmd_BG_FILL(struct Core *core); 39 | enum ErrorCode cmd_BG_TINT(struct Core *core); 40 | enum ErrorCode cmd_CELL(struct Core *core); 41 | struct TypedValue fnc_CELL(struct Core *core); 42 | enum ErrorCode cmd_MCELL(struct Core *core); 43 | struct TypedValue fnc_MCELL(struct Core *core); 44 | enum ErrorCode cmd_TINT(struct Core *core); 45 | 46 | #endif /* cmd_background_h */ 47 | -------------------------------------------------------------------------------- /core/interpreter/cmd_control.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright 2017-2020 Timo Kloss 3 | // 4 | // This software is provided 'as-is', without any express or implied 5 | // warranty. In no event will the authors be held liable for any damages 6 | // arising from the use of this software. 7 | // 8 | // Permission is granted to anyone to use this software for any purpose, 9 | // including commercial applications, and to alter it and redistribute it 10 | // freely, subject to the following restrictions: 11 | // 12 | // 1. The origin of this software must not be misrepresented; you must not 13 | // claim that you wrote the original software. If you use this software 14 | // in a product, an acknowledgment in the product documentation would be 15 | // appreciated but is not required. 16 | // 2. Altered source versions must be plainly marked as such, and must not be 17 | // misrepresented as being the original software. 18 | // 3. This notice may not be removed or altered from any source distribution. 19 | // 20 | 21 | #ifndef cmd_control_h 22 | #define cmd_control_h 23 | 24 | #include 25 | #include 26 | #include "error.h" 27 | 28 | struct Core; 29 | 30 | enum ErrorCode cmd_END(struct Core *core); 31 | enum ErrorCode cmd_IF(struct Core *core, bool isAfterBlockElse); 32 | enum ErrorCode cmd_ELSE(struct Core *core); 33 | enum ErrorCode cmd_END_IF(struct Core *core); 34 | enum ErrorCode cmd_FOR(struct Core *core); 35 | enum ErrorCode cmd_NEXT(struct Core *core); 36 | enum ErrorCode cmd_GOTO(struct Core *core); 37 | enum ErrorCode cmd_GOSUB(struct Core *core); 38 | enum ErrorCode cmd_RETURN(struct Core *core); 39 | enum ErrorCode cmd_WAIT(struct Core *core); 40 | enum ErrorCode cmd_ON(struct Core *core); 41 | enum ErrorCode cmd_DO(struct Core *core); 42 | enum ErrorCode cmd_LOOP(struct Core *core); 43 | enum ErrorCode cmd_REPEAT(struct Core *core); 44 | enum ErrorCode cmd_UNTIL(struct Core *core); 45 | enum ErrorCode cmd_WHILE(struct Core *core); 46 | enum ErrorCode cmd_WEND(struct Core *core); 47 | enum ErrorCode cmd_EXIT(struct Core *core); 48 | enum ErrorCode cmd_SYSTEM(struct Core *core); 49 | 50 | #endif /* cmd_control_h */ 51 | -------------------------------------------------------------------------------- /core/interpreter/cmd_data.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright 2017 Timo Kloss 3 | // 4 | // This software is provided 'as-is', without any express or implied 5 | // warranty. In no event will the authors be held liable for any damages 6 | // arising from the use of this software. 7 | // 8 | // Permission is granted to anyone to use this software for any purpose, 9 | // including commercial applications, and to alter it and redistribute it 10 | // freely, subject to the following restrictions: 11 | // 12 | // 1. The origin of this software must not be misrepresented; you must not 13 | // claim that you wrote the original software. If you use this software 14 | // in a product, an acknowledgment in the product documentation would be 15 | // appreciated but is not required. 16 | // 2. Altered source versions must be plainly marked as such, and must not be 17 | // misrepresented as being the original software. 18 | // 3. This notice may not be removed or altered from any source distribution. 19 | // 20 | 21 | #ifndef cmd_data_h 22 | #define cmd_data_h 23 | 24 | #include 25 | #include "error.h" 26 | 27 | struct Core; 28 | 29 | enum ErrorCode cmd_DATA(struct Core *core); 30 | enum ErrorCode cmd_READ(struct Core *core); 31 | enum ErrorCode cmd_RESTORE(struct Core *core); 32 | 33 | #endif /* cmd_data_h */ 34 | -------------------------------------------------------------------------------- /core/interpreter/cmd_files.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright 2017 Timo Kloss 3 | // 4 | // This software is provided 'as-is', without any express or implied 5 | // warranty. In no event will the authors be held liable for any damages 6 | // arising from the use of this software. 7 | // 8 | // Permission is granted to anyone to use this software for any purpose, 9 | // including commercial applications, and to alter it and redistribute it 10 | // freely, subject to the following restrictions: 11 | // 12 | // 1. The origin of this software must not be misrepresented; you must not 13 | // claim that you wrote the original software. If you use this software 14 | // in a product, an acknowledgment in the product documentation would be 15 | // appreciated but is not required. 16 | // 2. Altered source versions must be plainly marked as such, and must not be 17 | // misrepresented as being the original software. 18 | // 3. This notice may not be removed or altered from any source distribution. 19 | // 20 | 21 | #ifndef cmd_files_h 22 | #define cmd_files_h 23 | 24 | #include 25 | #include "error.h" 26 | #include "value.h" 27 | 28 | struct Core; 29 | 30 | enum ErrorCode cmd_LOAD(struct Core *core); 31 | enum ErrorCode cmd_SAVE(struct Core *core); 32 | enum ErrorCode cmd_FILES(struct Core *core); 33 | struct TypedValue fnc_FILE(struct Core *core); 34 | struct TypedValue fnc_FSIZE(struct Core *core); 35 | 36 | #endif /* cmd_files_h */ 37 | -------------------------------------------------------------------------------- /core/interpreter/cmd_io.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright 2017 Timo Kloss 3 | // 4 | // This software is provided 'as-is', without any express or implied 5 | // warranty. In no event will the authors be held liable for any damages 6 | // arising from the use of this software. 7 | // 8 | // Permission is granted to anyone to use this software for any purpose, 9 | // including commercial applications, and to alter it and redistribute it 10 | // freely, subject to the following restrictions: 11 | // 12 | // 1. The origin of this software must not be misrepresented; you must not 13 | // claim that you wrote the original software. If you use this software 14 | // in a product, an acknowledgment in the product documentation would be 15 | // appreciated but is not required. 16 | // 2. Altered source versions must be plainly marked as such, and must not be 17 | // misrepresented as being the original software. 18 | // 3. This notice may not be removed or altered from any source distribution. 19 | // 20 | 21 | #ifndef cmd_io_h 22 | #define cmd_io_h 23 | 24 | #include 25 | #include "error.h" 26 | #include "value.h" 27 | 28 | struct Core; 29 | 30 | enum ErrorCode cmd_KEYBOARD(struct Core *core); 31 | enum ErrorCode cmd_TOUCHSCREEN(struct Core *core); 32 | enum ErrorCode cmd_GAMEPAD(struct Core *core); 33 | enum ErrorCode cmd_PAUSE(struct Core *core); 34 | struct TypedValue fnc_UP_DOWN_LEFT_RIGHT(struct Core *core); 35 | struct TypedValue fnc_BUTTON(struct Core *core); 36 | struct TypedValue fnc_TOUCH(struct Core *core); 37 | struct TypedValue fnc_TAP(struct Core *core); 38 | struct TypedValue fnc_TOUCH_X_Y(struct Core *core); 39 | struct TypedValue fnc_PAUSE(struct Core *core); 40 | 41 | #endif /* cmd_io_h */ 42 | -------------------------------------------------------------------------------- /core/interpreter/cmd_maths.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright 2017 Timo Kloss 3 | // 4 | // This software is provided 'as-is', without any express or implied 5 | // warranty. In no event will the authors be held liable for any damages 6 | // arising from the use of this software. 7 | // 8 | // Permission is granted to anyone to use this software for any purpose, 9 | // including commercial applications, and to alter it and redistribute it 10 | // freely, subject to the following restrictions: 11 | // 12 | // 1. The origin of this software must not be misrepresented; you must not 13 | // claim that you wrote the original software. If you use this software 14 | // in a product, an acknowledgment in the product documentation would be 15 | // appreciated but is not required. 16 | // 2. Altered source versions must be plainly marked as such, and must not be 17 | // misrepresented as being the original software. 18 | // 3. This notice may not be removed or altered from any source distribution. 19 | // 20 | 21 | #ifndef cmd_maths_h 22 | #define cmd_maths_h 23 | 24 | #include 25 | #include "value.h" 26 | 27 | struct Core; 28 | 29 | struct TypedValue fnc_math0(struct Core *core); 30 | struct TypedValue fnc_math1(struct Core *core); 31 | struct TypedValue fnc_math2(struct Core *core); 32 | enum ErrorCode cmd_RANDOMIZE(struct Core *core); 33 | struct TypedValue fnc_RND(struct Core *core); 34 | enum ErrorCode cmd_ADD(struct Core *core); 35 | enum ErrorCode cmd_INC_DEC(struct Core *core); 36 | 37 | #endif /* cmd_maths_h */ 38 | -------------------------------------------------------------------------------- /core/interpreter/cmd_memory.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright 2017 Timo Kloss 3 | // 4 | // This software is provided 'as-is', without any express or implied 5 | // warranty. In no event will the authors be held liable for any damages 6 | // arising from the use of this software. 7 | // 8 | // Permission is granted to anyone to use this software for any purpose, 9 | // including commercial applications, and to alter it and redistribute it 10 | // freely, subject to the following restrictions: 11 | // 12 | // 1. The origin of this software must not be misrepresented; you must not 13 | // claim that you wrote the original software. If you use this software 14 | // in a product, an acknowledgment in the product documentation would be 15 | // appreciated but is not required. 16 | // 2. Altered source versions must be plainly marked as such, and must not be 17 | // misrepresented as being the original software. 18 | // 3. This notice may not be removed or altered from any source distribution. 19 | // 20 | 21 | #ifndef cmd_memory_h 22 | #define cmd_memory_h 23 | 24 | #include 25 | #include "error.h" 26 | 27 | struct Core; 28 | 29 | struct TypedValue fnc_PEEK(struct Core *core); 30 | enum ErrorCode cmd_POKE(struct Core *core); 31 | enum ErrorCode cmd_FILL(struct Core *core); 32 | enum ErrorCode cmd_COPY(struct Core *core); 33 | struct TypedValue fnc_ROM_SIZE(struct Core *core); 34 | enum ErrorCode cmd_ROL_ROR(struct Core *core); 35 | 36 | #endif /* cmd_memory_h */ 37 | -------------------------------------------------------------------------------- /core/interpreter/cmd_screen.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright 2017 Timo Kloss 3 | // 4 | // This software is provided 'as-is', without any express or implied 5 | // warranty. In no event will the authors be held liable for any damages 6 | // arising from the use of this software. 7 | // 8 | // Permission is granted to anyone to use this software for any purpose, 9 | // including commercial applications, and to alter it and redistribute it 10 | // freely, subject to the following restrictions: 11 | // 12 | // 1. The origin of this software must not be misrepresented; you must not 13 | // claim that you wrote the original software. If you use this software 14 | // in a product, an acknowledgment in the product documentation would be 15 | // appreciated but is not required. 16 | // 2. Altered source versions must be plainly marked as such, and must not be 17 | // misrepresented as being the original software. 18 | // 3. This notice may not be removed or altered from any source distribution. 19 | // 20 | 21 | #ifndef cmd_screen_h 22 | #define cmd_screen_h 23 | 24 | #include 25 | #include "error.h" 26 | #include "value.h" 27 | 28 | struct Core; 29 | 30 | enum ErrorCode cmd_PALETTE(struct Core *core); 31 | enum ErrorCode cmd_SCROLL(struct Core *core); 32 | enum ErrorCode cmd_DISPLAY(struct Core *core); 33 | enum ErrorCode cmd_SPRITE_VIEW(struct Core *core); 34 | enum ErrorCode cmd_BG_VIEW(struct Core *core); 35 | enum ErrorCode cmd_CELL_SIZE(struct Core *core); 36 | struct TypedValue fnc_COLOR(struct Core *core); 37 | struct TypedValue fnc_screen0(struct Core *core); 38 | struct TypedValue fnc_SCROLL_X_Y(struct Core *core); 39 | 40 | #endif /* cmd_screen_h */ 41 | -------------------------------------------------------------------------------- /core/interpreter/cmd_sprites.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright 2017 Timo Kloss 3 | // 4 | // This software is provided 'as-is', without any express or implied 5 | // warranty. In no event will the authors be held liable for any damages 6 | // arising from the use of this software. 7 | // 8 | // Permission is granted to anyone to use this software for any purpose, 9 | // including commercial applications, and to alter it and redistribute it 10 | // freely, subject to the following restrictions: 11 | // 12 | // 1. The origin of this software must not be misrepresented; you must not 13 | // claim that you wrote the original software. If you use this software 14 | // in a product, an acknowledgment in the product documentation would be 15 | // appreciated but is not required. 16 | // 2. Altered source versions must be plainly marked as such, and must not be 17 | // misrepresented as being the original software. 18 | // 3. This notice may not be removed or altered from any source distribution. 19 | // 20 | 21 | #ifndef cmd_sprites_h 22 | #define cmd_sprites_h 23 | 24 | #include 25 | #include "error.h" 26 | #include "value.h" 27 | 28 | struct Core; 29 | 30 | enum ErrorCode cmd_SPRITE(struct Core *core); 31 | enum ErrorCode cmd_SPRITE_A(struct Core *core); 32 | enum ErrorCode cmd_SPRITE_OFF(struct Core *core); 33 | struct TypedValue fnc_SPRITE(struct Core *core); 34 | struct TypedValue fnc_SPRITE_HIT(struct Core *core); 35 | struct TypedValue fnc_HIT(struct Core *core); 36 | 37 | #endif /* cmd_sprites_h */ 38 | -------------------------------------------------------------------------------- /core/interpreter/cmd_strings.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright 2017 Timo Kloss 3 | // 4 | // This software is provided 'as-is', without any express or implied 5 | // warranty. In no event will the authors be held liable for any damages 6 | // arising from the use of this software. 7 | // 8 | // Permission is granted to anyone to use this software for any purpose, 9 | // including commercial applications, and to alter it and redistribute it 10 | // freely, subject to the following restrictions: 11 | // 12 | // 1. The origin of this software must not be misrepresented; you must not 13 | // claim that you wrote the original software. If you use this software 14 | // in a product, an acknowledgment in the product documentation would be 15 | // appreciated but is not required. 16 | // 2. Altered source versions must be plainly marked as such, and must not be 17 | // misrepresented as being the original software. 18 | // 3. This notice may not be removed or altered from any source distribution. 19 | // 20 | 21 | #ifndef cmd_strings_h 22 | #define cmd_strings_h 23 | 24 | #include 25 | #include "value.h" 26 | 27 | struct Core; 28 | 29 | struct TypedValue fnc_ASC(struct Core *core); 30 | struct TypedValue fnc_BIN_HEX(struct Core *core); 31 | struct TypedValue fnc_CHR(struct Core *core); 32 | struct TypedValue fnc_INKEY(struct Core *core); 33 | struct TypedValue fnc_INSTR(struct Core *core); 34 | struct TypedValue fnc_LEFTStr_RIGHTStr(struct Core *core); 35 | struct TypedValue fnc_LEN(struct Core *core); 36 | struct TypedValue fnc_MID(struct Core *core); 37 | struct TypedValue fnc_STR(struct Core *core); 38 | struct TypedValue fnc_VAL(struct Core *core); 39 | 40 | enum ErrorCode cmd_LEFT_RIGHT(struct Core *core); 41 | enum ErrorCode cmd_MID(struct Core *core); 42 | 43 | #endif /* cmd_strings_h */ 44 | -------------------------------------------------------------------------------- /core/interpreter/cmd_subs.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright 2018 Timo Kloss 3 | // 4 | // This software is provided 'as-is', without any express or implied 5 | // warranty. In no event will the authors be held liable for any damages 6 | // arising from the use of this software. 7 | // 8 | // Permission is granted to anyone to use this software for any purpose, 9 | // including commercial applications, and to alter it and redistribute it 10 | // freely, subject to the following restrictions: 11 | // 12 | // 1. The origin of this software must not be misrepresented; you must not 13 | // claim that you wrote the original software. If you use this software 14 | // in a product, an acknowledgment in the product documentation would be 15 | // appreciated but is not required. 16 | // 2. Altered source versions must be plainly marked as such, and must not be 17 | // misrepresented as being the original software. 18 | // 3. This notice may not be removed or altered from any source distribution. 19 | // 20 | 21 | #ifndef cmd_subs_h 22 | #define cmd_subs_h 23 | 24 | #include 25 | #include "error.h" 26 | 27 | struct Core; 28 | 29 | enum ErrorCode cmd_CALL(struct Core *core); 30 | enum ErrorCode cmd_SUB(struct Core *core); 31 | enum ErrorCode cmd_END_SUB(struct Core *core); 32 | //enum ErrorCode cmd_SHARED(struct Core *core); 33 | enum ErrorCode cmd_GLOBAL(struct Core *core); 34 | enum ErrorCode cmd_EXIT_SUB(struct Core *core); 35 | 36 | #endif /* cmd_subs_h */ 37 | -------------------------------------------------------------------------------- /core/interpreter/cmd_text.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright 2017-2020 Timo Kloss 3 | // 4 | // This software is provided 'as-is', without any express or implied 5 | // warranty. In no event will the authors be held liable for any damages 6 | // arising from the use of this software. 7 | // 8 | // Permission is granted to anyone to use this software for any purpose, 9 | // including commercial applications, and to alter it and redistribute it 10 | // freely, subject to the following restrictions: 11 | // 12 | // 1. The origin of this software must not be misrepresented; you must not 13 | // claim that you wrote the original software. If you use this software 14 | // in a product, an acknowledgment in the product documentation would be 15 | // appreciated but is not required. 16 | // 2. Altered source versions must be plainly marked as such, and must not be 17 | // misrepresented as being the original software. 18 | // 3. This notice may not be removed or altered from any source distribution. 19 | // 20 | 21 | #ifndef cmd_text_h 22 | #define cmd_text_h 23 | 24 | #include 25 | #include 26 | #include "error.h" 27 | 28 | struct Core; 29 | 30 | enum ErrorCode cmd_PRINT(struct Core *core); 31 | enum ErrorCode cmd_INPUT(struct Core *core); 32 | enum ErrorCode cmd_endINPUT(struct Core *core); 33 | enum ErrorCode cmd_TEXT(struct Core *core); 34 | enum ErrorCode cmd_NUMBER(struct Core *core); 35 | enum ErrorCode cmd_CLS(struct Core *core); 36 | enum ErrorCode cmd_WINDOW(struct Core *core); 37 | enum ErrorCode cmd_FONT(struct Core *core); 38 | enum ErrorCode cmd_LOCATE(struct Core *core); 39 | struct TypedValue fnc_CURSOR(struct Core *core); 40 | enum ErrorCode cmd_CLW(struct Core *core); 41 | enum ErrorCode cmd_TRACE(struct Core *core); 42 | 43 | #endif /* cmd_text_h */ 44 | -------------------------------------------------------------------------------- /core/interpreter/cmd_variables.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright 2017-2020 Timo Kloss 3 | // 4 | // This software is provided 'as-is', without any express or implied 5 | // warranty. In no event will the authors be held liable for any damages 6 | // arising from the use of this software. 7 | // 8 | // Permission is granted to anyone to use this software for any purpose, 9 | // including commercial applications, and to alter it and redistribute it 10 | // freely, subject to the following restrictions: 11 | // 12 | // 1. The origin of this software must not be misrepresented; you must not 13 | // claim that you wrote the original software. If you use this software 14 | // in a product, an acknowledgment in the product documentation would be 15 | // appreciated but is not required. 16 | // 2. Altered source versions must be plainly marked as such, and must not be 17 | // misrepresented as being the original software. 18 | // 3. This notice may not be removed or altered from any source distribution. 19 | // 20 | 21 | #ifndef cmd_variables_h 22 | #define cmd_variables_h 23 | 24 | #include 25 | #include "error.h" 26 | 27 | struct Core; 28 | 29 | enum ErrorCode cmd_LET(struct Core *core); 30 | enum ErrorCode cmd_DIM(struct Core *core); 31 | struct TypedValue fnc_UBOUND(struct Core *core); 32 | enum ErrorCode cmd_SWAP(struct Core *core); 33 | 34 | #endif /* cmd_variables_h */ 35 | -------------------------------------------------------------------------------- /core/interpreter/data.c: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright 2017 Timo Kloss 3 | // 4 | // This software is provided 'as-is', without any express or implied 5 | // warranty. In no event will the authors be held liable for any damages 6 | // arising from the use of this software. 7 | // 8 | // Permission is granted to anyone to use this software for any purpose, 9 | // including commercial applications, and to alter it and redistribute it 10 | // freely, subject to the following restrictions: 11 | // 12 | // 1. The origin of this software must not be misrepresented; you must not 13 | // claim that you wrote the original software. If you use this software 14 | // in a product, an acknowledgment in the product documentation would be 15 | // appreciated but is not required. 16 | // 2. Altered source versions must be plainly marked as such, and must not be 17 | // misrepresented as being the original software. 18 | // 3. This notice may not be removed or altered from any source distribution. 19 | // 20 | 21 | #include "data.h" 22 | #include "interpreter.h" 23 | 24 | void dat_nextData(struct Interpreter *interpreter) 25 | { 26 | interpreter->currentDataValueToken++; 27 | if (interpreter->currentDataValueToken->type == TokenComma) 28 | { 29 | // value follows 30 | interpreter->currentDataValueToken++; 31 | } 32 | else 33 | { 34 | // next DATA line 35 | interpreter->currentDataToken = interpreter->currentDataToken->jumpToken; 36 | if (interpreter->currentDataToken) 37 | { 38 | interpreter->currentDataValueToken = interpreter->currentDataToken + 1; // after DATA 39 | } 40 | else 41 | { 42 | interpreter->currentDataValueToken = NULL; 43 | } 44 | } 45 | } 46 | 47 | void dat_restoreData(struct Interpreter *interpreter, struct Token *jumpToken) 48 | { 49 | if (jumpToken) 50 | { 51 | struct Token *dataToken = interpreter->firstData; 52 | while (dataToken && dataToken < jumpToken) 53 | { 54 | dataToken = dataToken->jumpToken; 55 | } 56 | interpreter->currentDataToken = dataToken; 57 | } 58 | else 59 | { 60 | interpreter->currentDataToken = interpreter->firstData; 61 | } 62 | 63 | if (interpreter->currentDataToken) 64 | { 65 | interpreter->currentDataValueToken = interpreter->currentDataToken + 1; // after DATA 66 | } 67 | else 68 | { 69 | interpreter->currentDataValueToken = NULL; 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /core/interpreter/data.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright 2017 Timo Kloss 3 | // 4 | // This software is provided 'as-is', without any express or implied 5 | // warranty. In no event will the authors be held liable for any damages 6 | // arising from the use of this software. 7 | // 8 | // Permission is granted to anyone to use this software for any purpose, 9 | // including commercial applications, and to alter it and redistribute it 10 | // freely, subject to the following restrictions: 11 | // 12 | // 1. The origin of this software must not be misrepresented; you must not 13 | // claim that you wrote the original software. If you use this software 14 | // in a product, an acknowledgment in the product documentation would be 15 | // appreciated but is not required. 16 | // 2. Altered source versions must be plainly marked as such, and must not be 17 | // misrepresented as being the original software. 18 | // 3. This notice may not be removed or altered from any source distribution. 19 | // 20 | 21 | #ifndef data_h 22 | #define data_h 23 | 24 | #include 25 | 26 | struct Interpreter; 27 | struct Token; 28 | 29 | void dat_nextData(struct Interpreter *interpreter); 30 | void dat_restoreData(struct Interpreter *interpreter, struct Token *jumpToken); 31 | 32 | #endif /* data_h */ 33 | -------------------------------------------------------------------------------- /core/interpreter/error.c: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright 2017 Timo Kloss 3 | // 4 | // This software is provided 'as-is', without any express or implied 5 | // warranty. In no event will the authors be held liable for any damages 6 | // arising from the use of this software. 7 | // 8 | // Permission is granted to anyone to use this software for any purpose, 9 | // including commercial applications, and to alter it and redistribute it 10 | // freely, subject to the following restrictions: 11 | // 12 | // 1. The origin of this software must not be misrepresented; you must not 13 | // claim that you wrote the original software. If you use this software 14 | // in a product, an acknowledgment in the product documentation would be 15 | // appreciated but is not required. 16 | // 2. Altered source versions must be plainly marked as such, and must not be 17 | // misrepresented as being the original software. 18 | // 3. This notice may not be removed or altered from any source distribution. 19 | // 20 | 21 | #include "error.h" 22 | 23 | const char *ErrorStrings[] = { 24 | "OK", 25 | 26 | "Could Not Open Program", 27 | "Too Many Tokens", 28 | "ROM Is Full", 29 | "Index Already Defined", 30 | "Unterminated String", 31 | "Unexpected Character", 32 | "Reserved Keyword", 33 | "Syntax Error", 34 | "Symbol Name Too Long", 35 | "Too Many Symbols", 36 | "Type Mismatch", 37 | "Out Of Memory", 38 | "ELSE Without IF", 39 | "END IF Without IF", 40 | "Expected Command", 41 | "NEXT Without FOR", 42 | "LOOP Without DO", 43 | "UNTIL Without REPEAT", 44 | "WEND Without WHILE", 45 | "Label Already Defined", 46 | "Too Many Labels", 47 | "ErrorExpectedLabel", 48 | "Undefined Label", 49 | "Array Not Dimensionized", 50 | "Array Already Dimensionized", 51 | "Variable Already Used", 52 | "Index Out Of Bounds", 53 | "Wrong Number Of Dimensions", 54 | "Invalid Parameter", 55 | "RETURN Without GOSUB", 56 | "Stack Overflow", 57 | "Out Of Data", 58 | "Illegal Memory Access", 59 | "Too Many CPU Cycles In Interrupt", 60 | "Not Allowed In Interrupt", 61 | "IF Without END IF", 62 | "FOR Without NEXT", 63 | "DO Without LOOP", 64 | "REPEAT Without UNTIL", 65 | "WHILE Without WEND", 66 | "EXIT Not Inside Loop", 67 | "Directory Not Loaded", 68 | "Division By Zero", 69 | "Variable Not Initialized", 70 | "Array Variable Without Index", 71 | "END SUB Without SUB", 72 | "SUB Without END SUB", 73 | "SUB Cannot Be Nested", 74 | "Undefined Subprogram", 75 | "Expected Subprogram Name", 76 | "Argument Count Mismatch", 77 | "SUB Already Defined", 78 | "Too Many Subprograms", 79 | "SHARED Outside Of A Subprogram", 80 | "GLOBAL Inside Of A Subprogram", 81 | "EXIT SUB Outside Of A Subprogram", 82 | "Keyboard Not Enabled", 83 | "Automatic Pause Not Disabled", 84 | "Gamepad Not Enabled", 85 | "Touch Not Enabled", 86 | "Input Change Not Allowed", 87 | }; 88 | 89 | const char *err_getString(enum ErrorCode errorCode) 90 | { 91 | return ErrorStrings[errorCode]; 92 | } 93 | 94 | struct CoreError err_makeCoreError(enum ErrorCode code, int sourcePosition) 95 | { 96 | struct CoreError error = {code, sourcePosition}; 97 | return error; 98 | } 99 | 100 | struct CoreError err_noCoreError(void) 101 | { 102 | struct CoreError error = {ErrorNone, 0}; 103 | return error; 104 | } 105 | -------------------------------------------------------------------------------- /core/interpreter/error.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright 2017 Timo Kloss 3 | // 4 | // This software is provided 'as-is', without any express or implied 5 | // warranty. In no event will the authors be held liable for any damages 6 | // arising from the use of this software. 7 | // 8 | // Permission is granted to anyone to use this software for any purpose, 9 | // including commercial applications, and to alter it and redistribute it 10 | // freely, subject to the following restrictions: 11 | // 12 | // 1. The origin of this software must not be misrepresented; you must not 13 | // claim that you wrote the original software. If you use this software 14 | // in a product, an acknowledgment in the product documentation would be 15 | // appreciated but is not required. 16 | // 2. Altered source versions must be plainly marked as such, and must not be 17 | // misrepresented as being the original software. 18 | // 3. This notice may not be removed or altered from any source distribution. 19 | // 20 | 21 | #ifndef error_h 22 | #define error_h 23 | 24 | #include 25 | 26 | enum ErrorCode { 27 | ErrorNone, 28 | 29 | ErrorCouldNotOpenProgram, 30 | ErrorTooManyTokens, 31 | ErrorRomIsFull, 32 | ErrorIndexAlreadyDefined, 33 | ErrorUnterminatedString, 34 | ErrorUnexpectedCharacter, 35 | ErrorReservedKeyword, 36 | ErrorSyntax, 37 | ErrorSymbolNameTooLong, 38 | ErrorTooManySymbols, 39 | ErrorTypeMismatch, 40 | ErrorOutOfMemory, 41 | ErrorElseWithoutIf, 42 | ErrorEndIfWithoutIf, 43 | ErrorExpectedCommand, 44 | ErrorNextWithoutFor, 45 | ErrorLoopWithoutDo, 46 | ErrorUntilWithoutRepeat, 47 | ErrorWendWithoutWhile, 48 | ErrorLabelAlreadyDefined, 49 | ErrorTooManyLabels, 50 | ErrorExpectedLabel, 51 | ErrorUndefinedLabel, 52 | ErrorArrayNotDimensionized, 53 | ErrorArrayAlreadyDimensionized, 54 | ErrorVariableAlreadyUsed, 55 | ErrorIndexOutOfBounds, 56 | ErrorWrongNumberOfDimensions, 57 | ErrorInvalidParameter, 58 | ErrorReturnWithoutGosub, 59 | ErrorStackOverflow, 60 | ErrorOutOfData, 61 | ErrorIllegalMemoryAccess, 62 | ErrorTooManyCPUCyclesInInterrupt, 63 | ErrorNotAllowedInInterrupt, 64 | ErrorIfWithoutEndIf, 65 | ErrorForWithoutNext, 66 | ErrorDoWithoutLoop, 67 | ErrorRepeatWithoutUntil, 68 | ErrorWhileWithoutWend, 69 | ErrorExitNotInsideLoop, 70 | ErrorDirectoryNotLoaded, 71 | ErrorDivisionByZero, 72 | ErrorVariableNotInitialized, 73 | ErrorArrayVariableWithoutIndex, 74 | ErrorEndSubWithoutSub, 75 | ErrorSubWithoutEndSub, 76 | ErrorSubCannotBeNested, 77 | ErrorUndefinedSubprogram, 78 | ErrorExpectedSubprogramName, 79 | ErrorArgumentCountMismatch, 80 | ErrorSubAlreadyDefined, 81 | ErrorTooManySubprograms, 82 | ErrorSharedOutsideOfASubprogram, 83 | ErrorGlobalInsideOfASubprogram, 84 | ErrorExitSubOutsideOfASubprogram, 85 | ErrorKeyboardNotEnabled, 86 | ErrorAutomaticPauseNotDisabled, 87 | ErrorGamepadNotEnabled, 88 | ErrorTouchNotEnabled, 89 | ErrorInputChangeNotAllowed, 90 | }; 91 | 92 | struct CoreError { 93 | enum ErrorCode code; 94 | int sourcePosition; 95 | }; 96 | 97 | const char *err_getString(enum ErrorCode errorCode); 98 | struct CoreError err_makeCoreError(enum ErrorCode code, int sourcePosition); 99 | struct CoreError err_noCoreError(void); 100 | 101 | #endif /* error_h */ 102 | -------------------------------------------------------------------------------- /core/interpreter/interpreter_config.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright 2017-2020 Timo Kloss 3 | // 4 | // This software is provided 'as-is', without any express or implied 5 | // warranty. In no event will the authors be held liable for any damages 6 | // arising from the use of this software. 7 | // 8 | // Permission is granted to anyone to use this software for any purpose, 9 | // including commercial applications, and to alter it and redistribute it 10 | // freely, subject to the following restrictions: 11 | // 12 | // 1. The origin of this software must not be misrepresented; you must not 13 | // claim that you wrote the original software. If you use this software 14 | // in a product, an acknowledgment in the product documentation would be 15 | // appreciated but is not required. 16 | // 2. Altered source versions must be plainly marked as such, and must not be 17 | // misrepresented as being the original software. 18 | // 3. This notice may not be removed or altered from any source distribution. 19 | // 20 | 21 | #ifndef interpreter_config_h 22 | #define interpreter_config_h 23 | 24 | #define MAX_TOKENS 16384 25 | #define MAX_SYMBOLS 2048 26 | #define MAX_LABEL_STACK_ITEMS 128 27 | #define MAX_JUMP_LABEL_ITEMS 256 28 | #define MAX_SUB_ITEMS 256 29 | #define MAX_SIMPLE_VARIABLES 256 30 | #define MAX_ARRAY_VARIABLES 256 31 | #define SYMBOL_NAME_SIZE 21 32 | #define MAX_ARRAY_DIMENSIONS 4 33 | #define MAX_ARRAY_SIZE 32768 34 | #define MAX_CYCLES_TOTAL_PER_FRAME 17556 35 | #define MAX_CYCLES_PER_VBL 1140 36 | #define MAX_CYCLES_PER_RASTER 51 37 | #define TIMER_WRAP_VALUE 5184000 38 | 39 | #endif /* interpreter_config_h */ 40 | -------------------------------------------------------------------------------- /core/interpreter/interpreter_utils.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright 2017-2018 Timo Kloss 3 | // 4 | // This software is provided 'as-is', without any express or implied 5 | // warranty. In no event will the authors be held liable for any damages 6 | // arising from the use of this software. 7 | // 8 | // Permission is granted to anyone to use this software for any purpose, 9 | // including commercial applications, and to alter it and redistribute it 10 | // freely, subject to the following restrictions: 11 | // 12 | // 1. The origin of this software must not be misrepresented; you must not 13 | // claim that you wrote the original software. If you use this software 14 | // in a product, an acknowledgment in the product documentation would be 15 | // appreciated but is not required. 16 | // 2. Altered source versions must be plainly marked as such, and must not be 17 | // misrepresented as being the original software. 18 | // 3. This notice may not be removed or altered from any source distribution. 19 | // 20 | 21 | #ifndef interpreter_utils_h 22 | #define interpreter_utils_h 23 | 24 | #include 25 | #include 26 | #include "value.h" 27 | #include "video_chip.h" 28 | #include "audio_chip.h" 29 | 30 | struct Core; 31 | 32 | struct SimpleAttributes 33 | { 34 | int pal; 35 | int flipX; 36 | int flipY; 37 | int prio; 38 | int size; 39 | }; 40 | 41 | enum ErrorCode itp_evaluateSimpleAttributes(struct Core *core, struct SimpleAttributes *attrs); 42 | 43 | struct TypedValue itp_evaluateCharAttributes(struct Core *core, union CharacterAttributes oldAttr); 44 | struct TypedValue itp_evaluateDisplayAttributes(struct Core *core, union DisplayAttributes oldAttr); 45 | struct TypedValue itp_evaluateLFOAttributes(struct Core *core, union LFOAttributes oldAttr); 46 | 47 | #endif /* interpreter_utils_h */ 48 | -------------------------------------------------------------------------------- /core/interpreter/labels.c: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright 2017 Timo Kloss 3 | // 4 | // This software is provided 'as-is', without any express or implied 5 | // warranty. In no event will the authors be held liable for any damages 6 | // arising from the use of this software. 7 | // 8 | // Permission is granted to anyone to use this software for any purpose, 9 | // including commercial applications, and to alter it and redistribute it 10 | // freely, subject to the following restrictions: 11 | // 12 | // 1. The origin of this software must not be misrepresented; you must not 13 | // claim that you wrote the original software. If you use this software 14 | // in a product, an acknowledgment in the product documentation would be 15 | // appreciated but is not required. 16 | // 2. Altered source versions must be plainly marked as such, and must not be 17 | // misrepresented as being the original software. 18 | // 3. This notice may not be removed or altered from any source distribution. 19 | // 20 | 21 | #include "labels.h" 22 | #include "interpreter.h" 23 | 24 | enum ErrorCode lab_pushLabelStackItem(struct Interpreter *interpreter, enum LabelType type, struct Token *token) 25 | { 26 | if (interpreter->numLabelStackItems >= MAX_LABEL_STACK_ITEMS) return ErrorStackOverflow; 27 | struct LabelStackItem *item = &interpreter->labelStackItems[interpreter->numLabelStackItems]; 28 | item->type = type; 29 | item->token = token; 30 | interpreter->numLabelStackItems++; 31 | return ErrorNone; 32 | } 33 | 34 | struct LabelStackItem *lab_popLabelStackItem(struct Interpreter *interpreter) 35 | { 36 | if (interpreter->numLabelStackItems > 0) 37 | { 38 | interpreter->numLabelStackItems--; 39 | return &interpreter->labelStackItems[interpreter->numLabelStackItems]; 40 | } 41 | return NULL; 42 | } 43 | 44 | struct LabelStackItem *lab_peekLabelStackItem(struct Interpreter *interpreter) 45 | { 46 | if (interpreter->numLabelStackItems > 0) 47 | { 48 | return &interpreter->labelStackItems[interpreter->numLabelStackItems - 1]; 49 | } 50 | return NULL; 51 | } 52 | 53 | struct LabelStackItem *lab_searchLabelStackItem(struct Interpreter *interpreter, enum LabelType types[], int numTypes) 54 | { 55 | int i = interpreter->numLabelStackItems - 1; 56 | while (i >= 0) 57 | { 58 | struct LabelStackItem *item = &interpreter->labelStackItems[i]; 59 | for (int j = 0; j < numTypes; j++) 60 | { 61 | if (item->type == types[j]) 62 | { 63 | return item; 64 | } 65 | } 66 | --i; 67 | } 68 | return NULL; 69 | } 70 | -------------------------------------------------------------------------------- /core/interpreter/labels.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright 2017 Timo Kloss 3 | // 4 | // This software is provided 'as-is', without any express or implied 5 | // warranty. In no event will the authors be held liable for any damages 6 | // arising from the use of this software. 7 | // 8 | // Permission is granted to anyone to use this software for any purpose, 9 | // including commercial applications, and to alter it and redistribute it 10 | // freely, subject to the following restrictions: 11 | // 12 | // 1. The origin of this software must not be misrepresented; you must not 13 | // claim that you wrote the original software. If you use this software 14 | // in a product, an acknowledgment in the product documentation would be 15 | // appreciated but is not required. 16 | // 2. Altered source versions must be plainly marked as such, and must not be 17 | // misrepresented as being the original software. 18 | // 3. This notice may not be removed or altered from any source distribution. 19 | // 20 | 21 | #ifndef labels_h 22 | #define labels_h 23 | 24 | #include 25 | 26 | struct Interpreter; 27 | struct Token; 28 | 29 | enum LabelType { 30 | LabelTypeIF, 31 | LabelTypeELSE, 32 | LabelTypeELSEIF, 33 | LabelTypeFOR, 34 | LabelTypeFORVar, 35 | LabelTypeFORLimit, 36 | LabelTypeGOSUB, 37 | LabelTypeDO, 38 | LabelTypeREPEAT, 39 | LabelTypeWHILE, 40 | LabelTypeSUB, 41 | LabelTypeCALL, 42 | LabelTypeONCALL, 43 | }; 44 | 45 | struct LabelStackItem { 46 | enum LabelType type; 47 | struct Token *token; 48 | }; 49 | 50 | enum ErrorCode lab_pushLabelStackItem(struct Interpreter *interpreter, enum LabelType type, struct Token *token); 51 | struct LabelStackItem *lab_popLabelStackItem(struct Interpreter *interpreter); 52 | struct LabelStackItem *lab_peekLabelStackItem(struct Interpreter *interpreter); 53 | struct LabelStackItem *lab_searchLabelStackItem(struct Interpreter *interpreter, enum LabelType types[], int numTypes); 54 | 55 | #endif /* labels_h */ 56 | -------------------------------------------------------------------------------- /core/interpreter/rcstring.c: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright 2017 Timo Kloss 3 | // 4 | // This software is provided 'as-is', without any express or implied 5 | // warranty. In no event will the authors be held liable for any damages 6 | // arising from the use of this software. 7 | // 8 | // Permission is granted to anyone to use this software for any purpose, 9 | // including commercial applications, and to alter it and redistribute it 10 | // freely, subject to the following restrictions: 11 | // 12 | // 1. The origin of this software must not be misrepresented; you must not 13 | // claim that you wrote the original software. If you use this software 14 | // in a product, an acknowledgment in the product documentation would be 15 | // appreciated but is not required. 16 | // 2. Altered source versions must be plainly marked as such, and must not be 17 | // misrepresented as being the original software. 18 | // 3. This notice may not be removed or altered from any source distribution. 19 | // 20 | 21 | #include "rcstring.h" 22 | #include 23 | #include 24 | 25 | struct RCString *rcstring_new(const char *chars, size_t len) 26 | { 27 | size_t size = sizeof(struct RCString) + len; 28 | struct RCString *string = malloc(size); 29 | if (string) 30 | { 31 | string->refCount = 1; // retain 32 | if (chars) 33 | { 34 | memcpy(string->chars, chars, len); 35 | } 36 | string->chars[len] = 0; // end of string 37 | } 38 | return string; 39 | } 40 | 41 | void rcstring_retain(struct RCString *string) 42 | { 43 | string->refCount++; 44 | } 45 | 46 | void rcstring_release(struct RCString *string) 47 | { 48 | string->refCount--; 49 | if (string->refCount == 0) 50 | { 51 | free((void *)string); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /core/interpreter/rcstring.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright 2017 Timo Kloss 3 | // 4 | // This software is provided 'as-is', without any express or implied 5 | // warranty. In no event will the authors be held liable for any damages 6 | // arising from the use of this software. 7 | // 8 | // Permission is granted to anyone to use this software for any purpose, 9 | // including commercial applications, and to alter it and redistribute it 10 | // freely, subject to the following restrictions: 11 | // 12 | // 1. The origin of this software must not be misrepresented; you must not 13 | // claim that you wrote the original software. If you use this software 14 | // in a product, an acknowledgment in the product documentation would be 15 | // appreciated but is not required. 16 | // 2. Altered source versions must be plainly marked as such, and must not be 17 | // misrepresented as being the original software. 18 | // 3. This notice may not be removed or altered from any source distribution. 19 | // 20 | 21 | #ifndef string_h 22 | #define string_h 23 | 24 | #include 25 | 26 | struct RCString { 27 | int refCount; 28 | char chars[1]; // ... 29 | }; 30 | 31 | struct RCString *rcstring_new(const char *chars, size_t len); 32 | void rcstring_retain(struct RCString *string); 33 | void rcstring_release(struct RCString *string); 34 | 35 | #endif /* string_h */ 36 | -------------------------------------------------------------------------------- /core/interpreter/string_utils.c: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright 2017 Timo Kloss 3 | // 4 | // This software is provided 'as-is', without any express or implied 5 | // warranty. In no event will the authors be held liable for any damages 6 | // arising from the use of this software. 7 | // 8 | // Permission is granted to anyone to use this software for any purpose, 9 | // including commercial applications, and to alter it and redistribute it 10 | // freely, subject to the following restrictions: 11 | // 12 | // 1. The origin of this software must not be misrepresented; you must not 13 | // claim that you wrote the original software. If you use this software 14 | // in a product, an acknowledgment in the product documentation would be 15 | // appreciated but is not required. 16 | // 2. Altered source versions must be plainly marked as such, and must not be 17 | // misrepresented as being the original software. 18 | // 3. This notice may not be removed or altered from any source distribution. 19 | // 20 | 21 | #include "string_utils.h" 22 | #include 23 | #include 24 | 25 | const char *uppercaseString(const char *source) 26 | { 27 | size_t len = strlen(source); 28 | char *buffer = malloc(len + 1); 29 | if (buffer) 30 | { 31 | const char *sourceChar = source; 32 | char *destChar = buffer; 33 | char finalChar = 0; 34 | while (*sourceChar) 35 | { 36 | finalChar = *sourceChar++; 37 | if (finalChar >= 'a' && finalChar <= 'z') 38 | { 39 | finalChar -= 32; 40 | } 41 | *destChar++ = finalChar; 42 | } 43 | *destChar = 0; 44 | } 45 | return buffer; 46 | } 47 | 48 | const char *lineString(const char *source, int pos) 49 | { 50 | const char *start = &source[pos]; 51 | const char *end = &source[pos]; 52 | while (start - 1 >= source && *(start - 1) != '\n') 53 | { 54 | start--; 55 | } 56 | while (*(end + 1) != 0 && *end != '\n' && *end != 0) 57 | { 58 | end++; 59 | } 60 | if (end > start) 61 | { 62 | size_t len = end - start; 63 | char *buffer = malloc(len + 1); 64 | if (buffer) 65 | { 66 | strncpy(buffer, start, len); 67 | buffer[len] = 0; 68 | return buffer; 69 | } 70 | } 71 | return NULL; 72 | } 73 | 74 | int lineNumber(const char *source, int pos) 75 | { 76 | int line = 1; 77 | for (int i = 0; i < pos; i++) 78 | { 79 | if (source[i] == '\n') 80 | { 81 | line++; 82 | } 83 | } 84 | return line; 85 | } 86 | 87 | void stringConvertCopy(char *dest, const char *source, size_t length) 88 | { 89 | char *currDstChar = dest; 90 | for (int i = 0; i < length; i++) 91 | { 92 | char currSrcChar = source[i]; 93 | if (currSrcChar != '\r') 94 | { 95 | *currDstChar = currSrcChar; 96 | currDstChar++; 97 | } 98 | } 99 | *currDstChar = 0; 100 | } 101 | -------------------------------------------------------------------------------- /core/interpreter/string_utils.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright 2017 Timo Kloss 3 | // 4 | // This software is provided 'as-is', without any express or implied 5 | // warranty. In no event will the authors be held liable for any damages 6 | // arising from the use of this software. 7 | // 8 | // Permission is granted to anyone to use this software for any purpose, 9 | // including commercial applications, and to alter it and redistribute it 10 | // freely, subject to the following restrictions: 11 | // 12 | // 1. The origin of this software must not be misrepresented; you must not 13 | // claim that you wrote the original software. If you use this software 14 | // in a product, an acknowledgment in the product documentation would be 15 | // appreciated but is not required. 16 | // 2. Altered source versions must be plainly marked as such, and must not be 17 | // misrepresented as being the original software. 18 | // 3. This notice may not be removed or altered from any source distribution. 19 | // 20 | 21 | #ifndef string_utils_h 22 | #define string_utils_h 23 | 24 | #include 25 | 26 | const char *uppercaseString(const char *source); 27 | const char *lineString(const char *source, int pos); 28 | int lineNumber(const char *source, int pos); 29 | void stringConvertCopy(char *dest, const char *source, size_t length); 30 | 31 | #endif /* string_utils_h */ 32 | -------------------------------------------------------------------------------- /core/interpreter/tokenizer.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright 2016-2017 Timo Kloss 3 | // 4 | // This software is provided 'as-is', without any express or implied 5 | // warranty. In no event will the authors be held liable for any damages 6 | // arising from the use of this software. 7 | // 8 | // Permission is granted to anyone to use this software for any purpose, 9 | // including commercial applications, and to alter it and redistribute it 10 | // freely, subject to the following restrictions: 11 | // 12 | // 1. The origin of this software must not be misrepresented; you must not 13 | // claim that you wrote the original software. If you use this software 14 | // in a product, an acknowledgment in the product documentation would be 15 | // appreciated but is not required. 16 | // 2. Altered source versions must be plainly marked as such, and must not be 17 | // misrepresented as being the original software. 18 | // 3. This notice may not be removed or altered from any source distribution. 19 | // 20 | 21 | #ifndef tokenizer_h 22 | #define tokenizer_h 23 | 24 | #include 25 | #include "interpreter_config.h" 26 | #include "token.h" 27 | 28 | struct Symbol { 29 | char name[SYMBOL_NAME_SIZE]; 30 | }; 31 | 32 | struct JumpLabelItem { 33 | int symbolIndex; 34 | struct Token *token; 35 | }; 36 | 37 | struct SubItem { 38 | int symbolIndex; 39 | struct Token *token; 40 | }; 41 | 42 | struct Tokenizer 43 | { 44 | struct Token tokens[MAX_TOKENS]; 45 | int numTokens; 46 | struct Symbol symbols[MAX_SYMBOLS]; 47 | int numSymbols; 48 | 49 | struct JumpLabelItem jumpLabelItems[MAX_JUMP_LABEL_ITEMS]; 50 | int numJumpLabelItems; 51 | struct SubItem subItems[MAX_SUB_ITEMS]; 52 | int numSubItems; 53 | }; 54 | 55 | struct CoreError tok_tokenizeProgram(struct Tokenizer *tokenizer, const char *sourceCode); 56 | struct CoreError tok_tokenizeUppercaseProgram(struct Tokenizer *tokenizer, const char *sourceCode); 57 | void tok_freeTokens(struct Tokenizer *tokenizer); 58 | struct JumpLabelItem *tok_getJumpLabel(struct Tokenizer *tokenizer, int symbolIndex); 59 | enum ErrorCode tok_setJumpLabel(struct Tokenizer *tokenizer, int symbolIndex, struct Token *token); 60 | struct SubItem *tok_getSub(struct Tokenizer *tokenizer, int symbolIndex); 61 | enum ErrorCode tok_setSub(struct Tokenizer *tokenizer, int symbolIndex, struct Token *token); 62 | 63 | #endif /* tokenizer_h */ 64 | -------------------------------------------------------------------------------- /core/interpreter/value.c: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright 2017 Timo Kloss 3 | // 4 | // This software is provided 'as-is', without any express or implied 5 | // warranty. In no event will the authors be held liable for any damages 6 | // arising from the use of this software. 7 | // 8 | // Permission is granted to anyone to use this software for any purpose, 9 | // including commercial applications, and to alter it and redistribute it 10 | // freely, subject to the following restrictions: 11 | // 12 | // 1. The origin of this software must not be misrepresented; you must not 13 | // claim that you wrote the original software. If you use this software 14 | // in a product, an acknowledgment in the product documentation would be 15 | // appreciated but is not required. 16 | // 2. Altered source versions must be plainly marked as such, and must not be 17 | // misrepresented as being the original software. 18 | // 3. This notice may not be removed or altered from any source distribution. 19 | // 20 | 21 | #include "value.h" 22 | 23 | union Value ValueDummy = {0}; 24 | 25 | struct TypedValue val_makeError(enum ErrorCode errorCode) 26 | { 27 | struct TypedValue value; 28 | value.type = ValueTypeError; 29 | value.v.errorCode = errorCode; 30 | return value; 31 | } 32 | -------------------------------------------------------------------------------- /core/interpreter/value.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright 2017 Timo Kloss 3 | // 4 | // This software is provided 'as-is', without any express or implied 5 | // warranty. In no event will the authors be held liable for any damages 6 | // arising from the use of this software. 7 | // 8 | // Permission is granted to anyone to use this software for any purpose, 9 | // including commercial applications, and to alter it and redistribute it 10 | // freely, subject to the following restrictions: 11 | // 12 | // 1. The origin of this software must not be misrepresented; you must not 13 | // claim that you wrote the original software. If you use this software 14 | // in a product, an acknowledgment in the product documentation would be 15 | // appreciated but is not required. 16 | // 2. Altered source versions must be plainly marked as such, and must not be 17 | // misrepresented as being the original software. 18 | // 3. This notice may not be removed or altered from any source distribution. 19 | // 20 | 21 | #ifndef value_h 22 | #define value_h 23 | 24 | #include 25 | #include "error.h" 26 | #include "rcstring.h" 27 | 28 | enum ValueType { 29 | ValueTypeNull, 30 | ValueTypeError, 31 | ValueTypeFloat, 32 | ValueTypeString 33 | }; 34 | 35 | union Value { 36 | float floatValue; 37 | struct RCString *stringValue; 38 | union Value *reference; 39 | enum ErrorCode errorCode; 40 | }; 41 | 42 | struct TypedValue { 43 | enum ValueType type; 44 | union Value v; 45 | }; 46 | 47 | enum TypeClass { 48 | TypeClassAny, 49 | TypeClassNumeric, 50 | TypeClassString 51 | }; 52 | 53 | extern union Value ValueDummy; 54 | 55 | struct TypedValue val_makeError(enum ErrorCode errorCode); 56 | 57 | #endif /* value_h */ 58 | -------------------------------------------------------------------------------- /core/interpreter/variables.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright 2017 Timo Kloss 3 | // 4 | // This software is provided 'as-is', without any express or implied 5 | // warranty. In no event will the authors be held liable for any damages 6 | // arising from the use of this software. 7 | // 8 | // Permission is granted to anyone to use this software for any purpose, 9 | // including commercial applications, and to alter it and redistribute it 10 | // freely, subject to the following restrictions: 11 | // 12 | // 1. The origin of this software must not be misrepresented; you must not 13 | // claim that you wrote the original software. If you use this software 14 | // in a product, an acknowledgment in the product documentation would be 15 | // appreciated but is not required. 16 | // 2. Altered source versions must be plainly marked as such, and must not be 17 | // misrepresented as being the original software. 18 | // 3. This notice may not be removed or altered from any source distribution. 19 | // 20 | 21 | #ifndef variables_h 22 | #define variables_h 23 | 24 | #include 25 | #include 26 | #include 27 | #include "interpreter_config.h" 28 | #include "value.h" 29 | 30 | #define SUB_LEVEL_GLOBAL -1 31 | 32 | struct Core; 33 | struct Interpreter; 34 | 35 | struct SimpleVariable { 36 | int symbolIndex; 37 | int8_t subLevel; 38 | int8_t isReference:1; 39 | enum ValueType type; 40 | union Value v; 41 | }; 42 | 43 | struct ArrayVariable { 44 | int symbolIndex; 45 | int8_t subLevel; 46 | int8_t isReference:1; 47 | enum ValueType type; 48 | int numDimensions; 49 | int dimensionSizes[MAX_ARRAY_DIMENSIONS]; 50 | int numValues; 51 | union Value *values; 52 | }; 53 | 54 | struct SimpleVariable *var_getSimpleVariable(struct Interpreter *interpreter, int symbolIndex, int subLevel); 55 | struct SimpleVariable *var_createSimpleVariable(struct Interpreter *interpreter, enum ErrorCode *errorCode, int symbolIndex, int subLevel, enum ValueType type, union Value *valueReference); 56 | void var_freeSimpleVariables(struct Interpreter *interpreter, int minSubLevel); 57 | 58 | struct ArrayVariable *var_getArrayVariable(struct Interpreter *interpreter, int symbolIndex, int subLevel); 59 | union Value *var_getArrayValue(struct Interpreter *interpreter, struct ArrayVariable *variable, int *indices); 60 | struct ArrayVariable *var_dimVariable(struct Interpreter *interpreter, enum ErrorCode *errorCode, int symbolIndex, int numDimensions, int *dimensionSizes); 61 | struct ArrayVariable *var_createArrayVariable(struct Interpreter *interpreter, enum ErrorCode *errorCode, int symbolIndex, int subLevel, struct ArrayVariable *arrayReference); 62 | void var_freeArrayVariables(struct Interpreter *interpreter, int minSubLevel); 63 | 64 | #endif /* variables_h */ 65 | -------------------------------------------------------------------------------- /core/libraries/audio_lib.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright 2018 Timo Kloss 3 | // 4 | // This software is provided 'as-is', without any express or implied 5 | // warranty. In no event will the authors be held liable for any damages 6 | // arising from the use of this software. 7 | // 8 | // Permission is granted to anyone to use this software for any purpose, 9 | // including commercial applications, and to alter it and redistribute it 10 | // freely, subject to the following restrictions: 11 | // 12 | // 1. The origin of this software must not be misrepresented; you must not 13 | // claim that you wrote the original software. If you use this software 14 | // in a product, an acknowledgment in the product documentation would be 15 | // appreciated but is not required. 16 | // 2. Altered source versions must be plainly marked as such, and must not be 17 | // misrepresented as being the original software. 18 | // 3. This notice may not be removed or altered from any source distribution. 19 | // 20 | 21 | #ifndef audio_lib_h 22 | #define audio_lib_h 23 | 24 | #include 25 | #include 26 | #include "audio_chip.h" 27 | 28 | #define NUM_SOUNDS 16 29 | #define NUM_PATTERNS 64 30 | #define NUM_TRACKS 64 31 | #define NUM_TRACK_ROWS 32 32 | 33 | struct Core; 34 | 35 | struct ComposerPlayer { 36 | int sourceAddress; 37 | int index; // pattern for music, otherwise track 38 | int speed; 39 | int tick; 40 | int row; 41 | bool willBreak; 42 | }; 43 | 44 | struct AudioLib { 45 | struct Core *core; 46 | int sourceAddress; 47 | 48 | struct ComposerPlayer musicPlayer; 49 | struct ComposerPlayer trackPlayers[NUM_VOICES]; 50 | }; 51 | 52 | void audlib_play(struct AudioLib *lib, int voiceIndex, float pitch, int len, int sound); 53 | void audlib_copySound(struct AudioLib *lib, int sourceAddress, int sound, int voiceIndex); 54 | void audlib_playMusic(struct AudioLib *lib, int startPattern); 55 | void audlib_playTrack(struct AudioLib *lib, int track, int voiceIndex); 56 | void audlib_stopAll(struct AudioLib *lib); 57 | void audlib_stopVoice(struct AudioLib *lib, int voiceIndex); 58 | void audlib_update(struct AudioLib *lib); 59 | 60 | #endif /* audio_lib_h */ 61 | -------------------------------------------------------------------------------- /core/libraries/default_characters.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright 2016 Timo Kloss 3 | // 4 | // This software is provided 'as-is', without any express or implied 5 | // warranty. In no event will the authors be held liable for any damages 6 | // arising from the use of this software. 7 | // 8 | // Permission is granted to anyone to use this software for any purpose, 9 | // including commercial applications, and to alter it and redistribute it 10 | // freely, subject to the following restrictions: 11 | // 12 | // 1. The origin of this software must not be misrepresented; you must not 13 | // claim that you wrote the original software. If you use this software 14 | // in a product, an acknowledgment in the product documentation would be 15 | // appreciated but is not required. 16 | // 2. Altered source versions must be plainly marked as such, and must not be 17 | // misrepresented as being the original software. 18 | // 3. This notice may not be removed or altered from any source distribution. 19 | // 20 | 21 | #ifndef default_characters_h 22 | #define default_characters_h 23 | 24 | #include 25 | #include 26 | 27 | extern uint8_t DefaultCharacters[][16]; 28 | 29 | #endif /* default_characters_h */ 30 | -------------------------------------------------------------------------------- /core/libraries/sprites_lib.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright 2017 Timo Kloss 3 | // 4 | // This software is provided 'as-is', without any express or implied 5 | // warranty. In no event will the authors be held liable for any damages 6 | // arising from the use of this software. 7 | // 8 | // Permission is granted to anyone to use this software for any purpose, 9 | // including commercial applications, and to alter it and redistribute it 10 | // freely, subject to the following restrictions: 11 | // 12 | // 1. The origin of this software must not be misrepresented; you must not 13 | // claim that you wrote the original software. If you use this software 14 | // in a product, an acknowledgment in the product documentation would be 15 | // appreciated but is not required. 16 | // 2. Altered source versions must be plainly marked as such, and must not be 17 | // misrepresented as being the original software. 18 | // 3. This notice may not be removed or altered from any source distribution. 19 | // 20 | 21 | #ifndef sprites_lib_h 22 | #define sprites_lib_h 23 | 24 | #include 25 | #include 26 | 27 | struct Core; 28 | struct Sprite; 29 | 30 | struct SpritesLib { 31 | struct Core *core; 32 | int lastHit; 33 | }; 34 | 35 | bool sprlib_isSpriteOnScreen(struct Sprite *sprite); 36 | bool sprlib_checkCollision(struct SpritesLib *lib, int checkIndex, int firstIndex, int lastIndex); 37 | 38 | #endif /* sprites_lib_h */ 39 | -------------------------------------------------------------------------------- /core/libraries/startup_sequence.c: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright 2017 Timo Kloss 3 | // 4 | // This software is provided 'as-is', without any express or implied 5 | // warranty. In no event will the authors be held liable for any damages 6 | // arising from the use of this software. 7 | // 8 | // Permission is granted to anyone to use this software for any purpose, 9 | // including commercial applications, and to alter it and redistribute it 10 | // freely, subject to the following restrictions: 11 | // 12 | // 1. The origin of this software must not be misrepresented; you must not 13 | // claim that you wrote the original software. If you use this software 14 | // in a product, an acknowledgment in the product documentation would be 15 | // appreciated but is not required. 16 | // 2. Altered source versions must be plainly marked as such, and must not be 17 | // misrepresented as being the original software. 18 | // 3. This notice may not be removed or altered from any source distribution. 19 | // 20 | 21 | #include "startup_sequence.h" 22 | #include "core.h" 23 | #include 24 | #include 25 | 26 | #define FONT_CHAR_OFFSET 192 27 | 28 | void runStartupSequence(struct Core *core) 29 | { 30 | struct DataEntry *entries = core->interpreter->romDataManager.entries; 31 | 32 | // init font and window 33 | struct TextLib *textLib = &core->interpreter->textLib; 34 | textLib->fontCharOffset = FONT_CHAR_OFFSET; 35 | txtlib_clearScreen(textLib); 36 | 37 | // default characters/font 38 | if (strcmp(entries[0].comment, "FONT") == 0) 39 | { 40 | memcpy(&core->machine->videoRam.characters[FONT_CHAR_OFFSET], &core->machine->cartridgeRom[entries[0].start], entries[0].length); 41 | } 42 | 43 | // default palettes 44 | uint8_t *colors = core->machine->colorRegisters.colors; 45 | 46 | colors[0] = (0 << 4) | (1 << 2) | 1; 47 | colors[1] = (3 << 4) | (3 << 2) | 3; 48 | colors[2] = (2 << 4) | (3 << 2) | 3; 49 | colors[3] = (0 << 4) | (0 << 2) | 0; 50 | 51 | colors[4] = 0; 52 | colors[5] = (3 << 4) | (2 << 2) | 0; 53 | colors[6] = (3 << 4) | (1 << 2) | 0; 54 | colors[7] = (0 << 4) | (0 << 2) | 0; 55 | 56 | colors[8] = 0; 57 | colors[9] = (3 << 4) | (3 << 2) | 0; 58 | colors[10] = (0 << 4) | (3 << 2) | 0; 59 | colors[11] = (0 << 4) | (0 << 2) | 0; 60 | 61 | colors[12] = 0; 62 | colors[13] = (3 << 4) | (3 << 2) | 3; 63 | colors[14] = (3 << 4) | (3 << 2) | 0; 64 | colors[15] = (0 << 4) | (0 << 2) | 0; 65 | 66 | for (int i = 0; i < 16; i += 4) 67 | { 68 | colors[16 + i] = 0; 69 | colors[17 + i] = (3 << 4) | (3 << 2) | 3; 70 | colors[18 + i] = (2 << 4) | (2 << 2) | 2; 71 | colors[19 + i] = (1 << 4) | (1 << 2) | 1; 72 | } 73 | 74 | // main palettes 75 | int palLen = entries[1].length; 76 | if (palLen > 32) palLen = 32; 77 | memcpy(core->machine->colorRegisters.colors, &core->machine->cartridgeRom[entries[1].start], palLen); 78 | 79 | // main characters 80 | memcpy(core->machine->videoRam.characters, &core->machine->cartridgeRom[entries[2].start], entries[2].length); 81 | 82 | // main background source 83 | int bgStart = entries[3].start; 84 | core->interpreter->textLib.sourceAddress = bgStart + 4; 85 | core->interpreter->textLib.sourceWidth = core->machine->cartridgeRom[bgStart + 2]; 86 | core->interpreter->textLib.sourceHeight = core->machine->cartridgeRom[bgStart + 3]; 87 | 88 | // voices 89 | for (int i = 0; i < NUM_VOICES; i++) 90 | { 91 | struct Voice *voice = &core->machine->audioRegisters.voices[i]; 92 | voice->attr.pulseWidth = 8; 93 | voice->status.volume = 15; 94 | voice->status.mix = 3; 95 | voice->envS = 15; 96 | } 97 | 98 | // main sound source 99 | core->interpreter->audioLib.sourceAddress = entries[15].start; 100 | } 101 | -------------------------------------------------------------------------------- /core/libraries/startup_sequence.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright 2017 Timo Kloss 3 | // 4 | // This software is provided 'as-is', without any express or implied 5 | // warranty. In no event will the authors be held liable for any damages 6 | // arising from the use of this software. 7 | // 8 | // Permission is granted to anyone to use this software for any purpose, 9 | // including commercial applications, and to alter it and redistribute it 10 | // freely, subject to the following restrictions: 11 | // 12 | // 1. The origin of this software must not be misrepresented; you must not 13 | // claim that you wrote the original software. If you use this software 14 | // in a product, an acknowledgment in the product documentation would be 15 | // appreciated but is not required. 16 | // 2. Altered source versions must be plainly marked as such, and must not be 17 | // misrepresented as being the original software. 18 | // 3. This notice may not be removed or altered from any source distribution. 19 | // 20 | 21 | #ifndef startup_sequence_h 22 | #define startup_sequence_h 23 | 24 | #include 25 | 26 | struct Core; 27 | 28 | void runStartupSequence(struct Core *core); 29 | 30 | #endif /* startup_sequence_h */ 31 | -------------------------------------------------------------------------------- /core/libraries/text_lib.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright 2016-2019 Timo Kloss 3 | // 4 | // This software is provided 'as-is', without any express or implied 5 | // warranty. In no event will the authors be held liable for any damages 6 | // arising from the use of this software. 7 | // 8 | // Permission is granted to anyone to use this software for any purpose, 9 | // including commercial applications, and to alter it and redistribute it 10 | // freely, subject to the following restrictions: 11 | // 12 | // 1. The origin of this software must not be misrepresented; you must not 13 | // claim that you wrote the original software. If you use this software 14 | // in a product, an acknowledgment in the product documentation would be 15 | // appreciated but is not required. 16 | // 2. Altered source versions must be plainly marked as such, and must not be 17 | // misrepresented as being the original software. 18 | // 3. This notice may not be removed or altered from any source distribution. 19 | // 20 | 21 | #ifndef text_lib_h 22 | #define text_lib_h 23 | 24 | #include 25 | #include 26 | #include 27 | #include "video_chip.h" 28 | 29 | #define INPUT_BUFFER_SIZE 256 30 | #define OVERLAY_BG 2 31 | 32 | struct Core; 33 | 34 | struct TextLib { 35 | struct Core *core; 36 | union CharacterAttributes charAttr; 37 | int fontCharOffset; 38 | int windowX; 39 | int windowY; 40 | int windowWidth; 41 | int windowHeight; 42 | int windowBg; 43 | int cursorX; 44 | int cursorY; 45 | int bg; 46 | int sourceAddress; 47 | int sourceWidth; 48 | int sourceHeight; 49 | char inputBuffer[INPUT_BUFFER_SIZE]; 50 | int inputLength; 51 | int blink; 52 | }; 53 | 54 | void txtlib_printText(struct TextLib *lib, const char *text); 55 | bool txtlib_deleteBackward(struct TextLib *lib); 56 | void txtlib_writeText(struct TextLib *lib, const char *text, int x, int y); 57 | void txtlib_writeNumber(struct TextLib *lib, int number, int digits, int x, int y); 58 | void txtlib_inputBegin(struct TextLib *lib); 59 | bool txtlib_inputUpdate(struct TextLib *lib); 60 | void txtlib_clearWindow(struct TextLib *lib); 61 | void txtlib_clearScreen(struct TextLib *lib); 62 | void txtlib_clearBackground(struct TextLib *lib, int bg); 63 | struct Cell *txtlib_getCell(struct TextLib *lib, int x, int y); 64 | void txtlib_setCell(struct TextLib *lib, int x, int y, int character); 65 | void txtlib_setCells(struct TextLib *lib, int fromX, int fromY, int toX, int toY, int character); 66 | void txtlib_setCellsAttr(struct TextLib *lib, int fromX, int fromY, int toX, int toY, int pal, int flipX, int flipY, int prio); 67 | void txtlib_scrollBackground(struct TextLib *lib, int fromX, int fromY, int toX, int toY, int deltaX, int deltaY); 68 | void txtlib_copyBackground(struct TextLib *lib, int srcX, int srcY, int width, int height, int dstX, int dstY); 69 | int txtlib_getSourceCell(struct TextLib *lib, int x, int y, bool getAttrs); 70 | bool txtlib_setSourceCell(struct TextLib *lib, int x, int y, int character); 71 | 72 | void txtlib_itobin(char *buffer, size_t buffersize, size_t width, int value); 73 | 74 | #endif /* text_lib_h */ 75 | -------------------------------------------------------------------------------- /core/machine/audio_chip.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright 2016-2020 Timo Kloss 3 | // 4 | // This software is provided 'as-is', without any express or implied 5 | // warranty. In no event will the authors be held liable for any damages 6 | // arising from the use of this software. 7 | // 8 | // Permission is granted to anyone to use this software for any purpose, 9 | // including commercial applications, and to alter it and redistribute it 10 | // freely, subject to the following restrictions: 11 | // 12 | // 1. The origin of this software must not be misrepresented; you must not 13 | // claim that you wrote the original software. If you use this software 14 | // in a product, an acknowledgment in the product documentation would be 15 | // appreciated but is not required. 16 | // 2. Altered source versions must be plainly marked as such, and must not be 17 | // misrepresented as being the original software. 18 | // 3. This notice may not be removed or altered from any source distribution. 19 | // 20 | 21 | #ifndef audio_chip_h 22 | #define audio_chip_h 23 | 24 | #include 25 | #include 26 | #include 27 | 28 | #define NUM_VOICES 4 29 | #define NUM_AUDIO_BUFFERS 6 30 | #define AUDIO_FILTER_BUFFER_SIZE 3 31 | 32 | // audio output channels for stereo 33 | #define NUM_CHANNELS 2 34 | 35 | struct Core; 36 | 37 | enum WaveType { 38 | WaveTypeSawtooth, 39 | WaveTypeTriangle, 40 | WaveTypePulse, 41 | WaveTypeNoise 42 | }; 43 | 44 | enum EnvState { 45 | EnvStateAttack, 46 | EnvStateDecay, 47 | EnvStateRelease 48 | }; 49 | 50 | union VoiceStatus { 51 | struct { 52 | uint8_t volume:4; 53 | uint8_t mix:2; 54 | uint8_t init:1; 55 | uint8_t gate:1; 56 | }; 57 | uint8_t value; 58 | }; 59 | 60 | union VoiceAttributes { 61 | struct { 62 | uint8_t pulseWidth:4; 63 | uint8_t wave:2; 64 | uint8_t timeout:1; 65 | }; 66 | uint8_t value; 67 | }; 68 | 69 | enum LFOWaveType { 70 | LFOWaveTypeTriangle, 71 | LFOWaveTypeSawtooth, 72 | LFOWaveTypeSquare, 73 | LFOWaveTypeRandom 74 | }; 75 | 76 | union LFOAttributes { 77 | struct { 78 | uint8_t wave:2; 79 | uint8_t invert:1; 80 | uint8_t envMode:1; 81 | uint8_t trigger:1; 82 | }; 83 | uint8_t value; 84 | }; 85 | 86 | struct Voice { 87 | uint8_t frequencyLow; 88 | uint8_t frequencyHigh; 89 | union VoiceStatus status; 90 | uint8_t peak; 91 | union VoiceAttributes attr; 92 | uint8_t length; 93 | struct { 94 | uint8_t envA:4; 95 | uint8_t envD:4; 96 | }; 97 | struct { 98 | uint8_t envS:4; 99 | uint8_t envR:4; 100 | }; 101 | union LFOAttributes lfoAttr; 102 | struct { 103 | uint8_t lfoFrequency:4; 104 | uint8_t lfoOscAmount:4; 105 | }; 106 | struct { 107 | uint8_t lfoVolAmount:4; 108 | uint8_t lfoPWAmount:4; 109 | }; 110 | uint8_t reserved2; 111 | }; 112 | 113 | struct AudioRegisters { 114 | struct Voice voices[NUM_VOICES]; 115 | }; 116 | 117 | struct VoiceInternals { 118 | double accumulator; 119 | uint16_t noiseRandom; 120 | double envCounter; 121 | enum EnvState envState; 122 | double lfoAccumulator; 123 | bool lfoHold; 124 | uint16_t lfoRandom; 125 | double timeoutCounter; 126 | }; 127 | 128 | struct AudioInternals { 129 | struct VoiceInternals voices[NUM_VOICES]; 130 | struct AudioRegisters buffers[NUM_AUDIO_BUFFERS]; 131 | int readBufferIndex; 132 | int writeBufferIndex; 133 | bool audioEnabled; 134 | int32_t filterBuffer[NUM_CHANNELS][AUDIO_FILTER_BUFFER_SIZE]; 135 | }; 136 | 137 | void audio_reset(struct Core *core); 138 | void audio_bufferRegisters(struct Core *core); 139 | void audio_renderAudio(struct Core *core, int16_t *output, int numSamples, int outputFrequency, int volume); 140 | 141 | #endif /* audio_chip_h */ 142 | -------------------------------------------------------------------------------- /core/machine/io_chip.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright 2016 Timo Kloss 3 | // 4 | // This software is provided 'as-is', without any express or implied 5 | // warranty. In no event will the authors be held liable for any damages 6 | // arising from the use of this software. 7 | // 8 | // Permission is granted to anyone to use this software for any purpose, 9 | // including commercial applications, and to alter it and redistribute it 10 | // freely, subject to the following restrictions: 11 | // 12 | // 1. The origin of this software must not be misrepresented; you must not 13 | // claim that you wrote the original software. If you use this software 14 | // in a product, an acknowledgment in the product documentation would be 15 | // appreciated but is not required. 16 | // 2. Altered source versions must be plainly marked as such, and must not be 17 | // misrepresented as being the original software. 18 | // 3. This notice may not be removed or altered from any source distribution. 19 | // 20 | 21 | #ifndef io_chip_h 22 | #define io_chip_h 23 | 24 | #include 25 | 26 | #define NUM_GAMEPADS 2 27 | 28 | // ================ Gamepad ================ 29 | 30 | union Gamepad { 31 | struct { 32 | uint8_t up:1; 33 | uint8_t down:1; 34 | uint8_t left:1; 35 | uint8_t right:1; 36 | uint8_t buttonA:1; 37 | uint8_t buttonB:1; 38 | }; 39 | uint8_t value; 40 | }; 41 | 42 | // ================ Status ================ 43 | 44 | union IOStatus { 45 | struct { 46 | uint8_t pause:1; 47 | uint8_t touch:1; 48 | }; 49 | uint8_t value; 50 | }; 51 | 52 | // ================ Attributes ================ 53 | 54 | union IOAttributes { 55 | struct { 56 | uint8_t gamepadsEnabled:2; // 0: off, 1...2: number of players 57 | uint8_t keyboardEnabled:1; 58 | uint8_t touchEnabled:1; 59 | }; 60 | uint8_t value; 61 | }; 62 | 63 | // =============================================== 64 | // ================ I/O Registers ================ 65 | // =============================================== 66 | 67 | struct IORegisters { 68 | union Gamepad gamepads[NUM_GAMEPADS]; // 2 bytes 69 | uint8_t touchX; 70 | uint8_t touchY; 71 | char key; 72 | union IOStatus status; 73 | union IOAttributes attr; 74 | }; 75 | 76 | #endif /* io_chip_h */ 77 | -------------------------------------------------------------------------------- /core/machine/machine.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright 2016 Timo Kloss 3 | // 4 | // This software is provided 'as-is', without any express or implied 5 | // warranty. In no event will the authors be held liable for any damages 6 | // arising from the use of this software. 7 | // 8 | // Permission is granted to anyone to use this software for any purpose, 9 | // including commercial applications, and to alter it and redistribute it 10 | // freely, subject to the following restrictions: 11 | // 12 | // 1. The origin of this software must not be misrepresented; you must not 13 | // claim that you wrote the original software. If you use this software 14 | // in a product, an acknowledgment in the product documentation would be 15 | // appreciated but is not required. 16 | // 2. Altered source versions must be plainly marked as such, and must not be 17 | // misrepresented as being the original software. 18 | // 3. This notice may not be removed or altered from any source distribution. 19 | // 20 | 21 | #ifndef machine_h 22 | #define machine_h 23 | 24 | #include 25 | #include 26 | #include 27 | #include "io_chip.h" 28 | #include "video_chip.h" 29 | #include "audio_chip.h" 30 | 31 | #define PERSISTENT_RAM_SIZE 4096 32 | 33 | struct Core; 34 | 35 | // 64 KB 36 | struct Machine { 37 | 38 | // 0x0000 39 | uint8_t cartridgeRom[0x8000]; // 32 KB 40 | 41 | // 0x8000 42 | struct VideoRam videoRam; // 8 KB 43 | 44 | // 0xA000 45 | uint8_t workingRam[0x4000]; // 16 KB 46 | 47 | // 0xE000 48 | uint8_t persistentRam[PERSISTENT_RAM_SIZE]; // 4 KB 49 | 50 | // 0xF000 51 | uint8_t reservedMemory[0xFE00 - 0xF000]; 52 | 53 | // 0xFE00 54 | struct SpriteRegisters spriteRegisters; // 256 B 55 | 56 | // 0xFF00 57 | struct ColorRegisters colorRegisters; // 32 B 58 | 59 | // 0xFF20 60 | struct VideoRegisters videoRegisters; 61 | uint8_t reservedVideo[0x20 - sizeof(struct VideoRegisters)]; 62 | 63 | // 0xFF40 64 | struct AudioRegisters audioRegisters; 65 | 66 | // 0xFF70 67 | struct IORegisters ioRegisters; 68 | uint8_t reservedIO[0x10 - sizeof(struct IORegisters)]; 69 | 70 | // 0xFF80 71 | uint8_t reservedRegisters[0x10000 - 0xFF80]; 72 | }; 73 | 74 | struct MachineInternals { 75 | struct AudioInternals audioInternals; 76 | bool hasAccessedPersistent; 77 | bool hasChangedPersistent; 78 | bool isEnergySaving; 79 | int energySavingTimer; 80 | }; 81 | 82 | void machine_init(struct Core *core); 83 | void machine_reset(struct Core *core, bool resetPersistent); 84 | int machine_peek(struct Core *core, int address); 85 | bool machine_poke(struct Core *core, int address, int value); 86 | void machine_enableAudio(struct Core *core); 87 | void machine_suspendEnergySaving(struct Core *core, int numUpdates); 88 | 89 | #endif /* machine_h */ 90 | -------------------------------------------------------------------------------- /core/machine/video_chip.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright 2016 Timo Kloss 3 | // 4 | // This software is provided 'as-is', without any express or implied 5 | // warranty. In no event will the authors be held liable for any damages 6 | // arising from the use of this software. 7 | // 8 | // Permission is granted to anyone to use this software for any purpose, 9 | // including commercial applications, and to alter it and redistribute it 10 | // freely, subject to the following restrictions: 11 | // 12 | // 1. The origin of this software must not be misrepresented; you must not 13 | // claim that you wrote the original software. If you use this software 14 | // in a product, an acknowledgment in the product documentation would be 15 | // appreciated but is not required. 16 | // 2. Altered source versions must be plainly marked as such, and must not be 17 | // misrepresented as being the original software. 18 | // 3. This notice may not be removed or altered from any source distribution. 19 | // 20 | 21 | #ifndef video_chip_h 22 | #define video_chip_h 23 | 24 | #include 25 | #include 26 | 27 | #define SCREEN_WIDTH 160 28 | #define SCREEN_HEIGHT 128 29 | #define NUM_CHARACTERS 256 30 | #define NUM_PALETTES 8 31 | #define PLANE_COLUMNS 32 32 | #define PLANE_ROWS 32 33 | #define NUM_SPRITES 64 34 | #define SPRITE_OFFSET_X 32 35 | #define SPRITE_OFFSET_Y 32 36 | 37 | struct Core; 38 | 39 | // ================ Character ================ 40 | 41 | // 16 bytes 42 | struct Character { 43 | uint8_t data[16]; 44 | }; 45 | 46 | // ================ Sprite ================ 47 | 48 | union CharacterAttributes { 49 | struct { 50 | uint8_t palette:3; 51 | uint8_t flipX:1; 52 | uint8_t flipY:1; 53 | uint8_t priority:1; 54 | uint8_t size:2; // 1x1 - 4x4 characters 55 | }; 56 | uint8_t value; 57 | }; 58 | 59 | // 4 bytes 60 | struct Sprite { 61 | uint8_t x; 62 | uint8_t y; 63 | uint8_t character; 64 | union CharacterAttributes attr; 65 | }; 66 | 67 | // ================ Cell ================ 68 | 69 | // 2 bytes 70 | struct Cell { 71 | uint8_t character; 72 | union CharacterAttributes attr; 73 | }; 74 | 75 | // ================ Plane ================ 76 | 77 | // 2048 bytes 78 | struct Plane { 79 | struct Cell cells[PLANE_ROWS][PLANE_COLUMNS]; 80 | }; 81 | 82 | // =========================================== 83 | // ================ Video RAM ================ 84 | // =========================================== 85 | 86 | // 8 KB 87 | struct VideoRam { 88 | struct Character characters[NUM_CHARACTERS]; // 4 KB 89 | struct Plane planeA; // 2 KB 90 | struct Plane planeB; // 2 KB 91 | }; 92 | 93 | // ================================================= 94 | // ================ Video Registers ================ 95 | // ================================================= 96 | 97 | struct SpriteRegisters { 98 | struct Sprite sprites[NUM_SPRITES]; // 256 bytes 99 | }; 100 | 101 | struct ColorRegisters { 102 | uint8_t colors[NUM_PALETTES * 4]; // 32 bytes 103 | }; 104 | 105 | union DisplayAttributes { 106 | struct { 107 | uint8_t spritesEnabled:1; 108 | uint8_t planeAEnabled:1; 109 | uint8_t planeBEnabled:1; 110 | uint8_t planeACellSize:1; 111 | uint8_t planeBCellSize:1; 112 | }; 113 | uint8_t value; 114 | }; 115 | 116 | union ScrollMSB { 117 | struct { 118 | uint8_t aX:1; 119 | uint8_t aY:1; 120 | uint8_t bX:1; 121 | uint8_t bY:1; 122 | }; 123 | uint8_t value; 124 | }; 125 | 126 | struct VideoRegisters { 127 | union DisplayAttributes attr; 128 | uint8_t scrollAX; 129 | uint8_t scrollAY; 130 | uint8_t scrollBX; 131 | uint8_t scrollBY; 132 | union ScrollMSB scrollMSB; 133 | uint8_t rasterLine; 134 | }; 135 | 136 | // =========================================== 137 | // ================ Functions ================ 138 | // =========================================== 139 | 140 | void video_renderScreen(struct Core *core, uint32_t *outputRGB); 141 | 142 | #endif /* video_chip_h */ 143 | -------------------------------------------------------------------------------- /core/overlay/overlay.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright 2017-2018 Timo Kloss 3 | // 4 | // This software is provided 'as-is', without any express or implied 5 | // warranty. In no event will the authors be held liable for any damages 6 | // arising from the use of this software. 7 | // 8 | // Permission is granted to anyone to use this software for any purpose, 9 | // including commercial applications, and to alter it and redistribute it 10 | // freely, subject to the following restrictions: 11 | // 12 | // 1. The origin of this software must not be misrepresented; you must not 13 | // claim that you wrote the original software. If you use this software 14 | // in a product, an acknowledgment in the product documentation would be 15 | // appreciated but is not required. 16 | // 2. Altered source versions must be plainly marked as such, and must not be 17 | // misrepresented as being the original software. 18 | // 3. This notice may not be removed or altered from any source distribution. 19 | // 20 | 21 | #ifndef overlay_h 22 | #define overlay_h 23 | 24 | #include 25 | #include 26 | #include "video_chip.h" 27 | #include "overlay_data.h" 28 | #include "text_lib.h" 29 | 30 | struct Core; 31 | 32 | struct Overlay { 33 | struct Plane plane; 34 | struct TextLib textLib; 35 | int timer; 36 | int messageTimer; 37 | }; 38 | 39 | void overlay_init(struct Core *core); 40 | void overlay_reset(struct Core *core); 41 | void overlay_updateState(struct Core *core); 42 | void overlay_message(struct Core *core, const char *message); 43 | void overlay_draw(struct Core *core, bool ingame); 44 | 45 | #endif /* overlay_h */ 46 | -------------------------------------------------------------------------------- /core/overlay/overlay_data.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright 2017-2018 Timo Kloss 3 | // 4 | // This software is provided 'as-is', without any express or implied 5 | // warranty. In no event will the authors be held liable for any damages 6 | // arising from the use of this software. 7 | // 8 | // Permission is granted to anyone to use this software for any purpose, 9 | // including commercial applications, and to alter it and redistribute it 10 | // freely, subject to the following restrictions: 11 | // 12 | // 1. The origin of this software must not be misrepresented; you must not 13 | // claim that you wrote the original software. If you use this software 14 | // in a product, an acknowledgment in the product documentation would be 15 | // appreciated but is not required. 16 | // 2. Altered source versions must be plainly marked as such, and must not be 17 | // misrepresented as being the original software. 18 | // 3. This notice may not be removed or altered from any source distribution. 19 | // 20 | 21 | #ifndef overlay_data_h 22 | #define overlay_data_h 23 | 24 | #include 25 | #include 26 | #include "video_chip.h" 27 | 28 | extern uint8_t overlayColors[]; 29 | extern uint8_t overlayCharacters[]; 30 | 31 | #endif /* overlay_data_h */ 32 | -------------------------------------------------------------------------------- /docs/license.txt: -------------------------------------------------------------------------------- 1 | Copyright 2016-2021 Timo Kloss 2 | 3 | This software is provided 'as-is', without any express or implied 4 | warranty. In no event will the authors be held liable for any damages 5 | arising from the use of this software. 6 | 7 | Permission is granted to anyone to use this software for any purpose, 8 | including commercial applications, and to alter it and redistribute it 9 | freely, subject to the following restrictions: 10 | 11 | 1. The origin of this software must not be misrepresented; you must not 12 | claim that you wrote the original software. If you use this software 13 | in a product, an acknowledgment in the product documentation would be 14 | appreciated but is not required. 15 | 2. Altered source versions must be plainly marked as such, and must not be 16 | misrepresented as being the original software. 17 | 3. This notice may not be removed or altered from any source distribution. 18 | -------------------------------------------------------------------------------- /docs/manual-images/icon_desktop.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timoinutilis/lowres-nx/85c80181d26bb5c2147ebc76bfc48bce9f8d73a8/docs/manual-images/icon_desktop.png -------------------------------------------------------------------------------- /docs/manual-images/icon_desktop@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timoinutilis/lowres-nx/85c80181d26bb5c2147ebc76bfc48bce9f8d73a8/docs/manual-images/icon_desktop@2x.png -------------------------------------------------------------------------------- /docs/manual-images/icon_mobile.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timoinutilis/lowres-nx/85c80181d26bb5c2147ebc76bfc48bce9f8d73a8/docs/manual-images/icon_mobile.png -------------------------------------------------------------------------------- /docs/manual-images/icon_mobile@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timoinutilis/lowres-nx/85c80181d26bb5c2147ebc76bfc48bce9f8d73a8/docs/manual-images/icon_mobile@2x.png -------------------------------------------------------------------------------- /docs/manual-images/illustration_building.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timoinutilis/lowres-nx/85c80181d26bb5c2147ebc76bfc48bce9f8d73a8/docs/manual-images/illustration_building.png -------------------------------------------------------------------------------- /docs/manual-images/illustration_building@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timoinutilis/lowres-nx/85c80181d26bb5c2147ebc76bfc48bce9f8d73a8/docs/manual-images/illustration_building@2x.png -------------------------------------------------------------------------------- /docs/manual-images/illustration_disk.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timoinutilis/lowres-nx/85c80181d26bb5c2147ebc76bfc48bce9f8d73a8/docs/manual-images/illustration_disk.png -------------------------------------------------------------------------------- /docs/manual-images/illustration_disk@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timoinutilis/lowres-nx/85c80181d26bb5c2147ebc76bfc48bce9f8d73a8/docs/manual-images/illustration_disk@2x.png -------------------------------------------------------------------------------- /docs/manual-images/illustration_hello.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timoinutilis/lowres-nx/85c80181d26bb5c2147ebc76bfc48bce9f8d73a8/docs/manual-images/illustration_hello.png -------------------------------------------------------------------------------- /docs/manual-images/illustration_hello@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timoinutilis/lowres-nx/85c80181d26bb5c2147ebc76bfc48bce9f8d73a8/docs/manual-images/illustration_hello@2x.png -------------------------------------------------------------------------------- /docs/manual-images/illustration_music.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timoinutilis/lowres-nx/85c80181d26bb5c2147ebc76bfc48bce9f8d73a8/docs/manual-images/illustration_music.png -------------------------------------------------------------------------------- /docs/manual-images/illustration_music@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timoinutilis/lowres-nx/85c80181d26bb5c2147ebc76bfc48bce9f8d73a8/docs/manual-images/illustration_music@2x.png -------------------------------------------------------------------------------- /docs/manual-images/illustration_open.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timoinutilis/lowres-nx/85c80181d26bb5c2147ebc76bfc48bce9f8d73a8/docs/manual-images/illustration_open.png -------------------------------------------------------------------------------- /docs/manual-images/illustration_open@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timoinutilis/lowres-nx/85c80181d26bb5c2147ebc76bfc48bce9f8d73a8/docs/manual-images/illustration_open@2x.png -------------------------------------------------------------------------------- /docs/manual-images/illustration_painting.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timoinutilis/lowres-nx/85c80181d26bb5c2147ebc76bfc48bce9f8d73a8/docs/manual-images/illustration_painting.png -------------------------------------------------------------------------------- /docs/manual-images/illustration_painting@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timoinutilis/lowres-nx/85c80181d26bb5c2147ebc76bfc48bce9f8d73a8/docs/manual-images/illustration_painting@2x.png -------------------------------------------------------------------------------- /docs/manual-images/illustration_playing.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timoinutilis/lowres-nx/85c80181d26bb5c2147ebc76bfc48bce9f8d73a8/docs/manual-images/illustration_playing.png -------------------------------------------------------------------------------- /docs/manual-images/illustration_playing@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timoinutilis/lowres-nx/85c80181d26bb5c2147ebc76bfc48bce9f8d73a8/docs/manual-images/illustration_playing@2x.png -------------------------------------------------------------------------------- /docs/readme.txt: -------------------------------------------------------------------------------- 1 | *************** 2 | * First Steps * 3 | *************** 4 | 5 | Please read the introduction (at least "Getting Started") of the manual. 6 | 7 | 8 | ************ 9 | * Controls * 10 | ************ 11 | 12 | - Use any real gamepad or the keyboard: 13 | 14 | Button Player 1 Player 2 15 | -------+-----------+-------- 16 | UP Arrow Up E 17 | DOWN Arrow Down D 18 | LEFT Arrow Left S 19 | RIGHT Arrow Right F 20 | A Z/N Q/Tab 21 | B X/M A/Shift 22 | 23 | - More keys: 24 | Dev Menu Esc 25 | Pause Return/P 26 | Fullscreen Ctrl+f 27 | Zoom Mode Ctrl+z 28 | Screenshot 29 | large Ctrl+s 30 | original Ctrl+Shift+s 31 | Debug Ctrl+d 32 | Reload/Run Ctrl+r 33 | Eject Ctrl+e 34 | Volume up Ctrl+Plus 35 | Volume down Ctrl+Minus 36 | Quit Esc (if disabledev) 37 | 38 | 39 | ************ 40 | * Settings * 41 | ************ 42 | 43 | - Settings file: 44 | A default settings file is created on application start, if none 45 | exists yet. Available options are the same as for command line 46 | arguments, but each one is written in its own line and without 47 | the leading "-" character. 48 | macOS: /Users/YourName/Library/Application Support/Inutilis Software/LowRes NX/settings.txt 49 | Windows: C:\Users\YourName\AppData\Roaming\Inutilis Software\LowRes NX\settings.txt 50 | 51 | - Command line arguments: 52 | These override the options from the settings file. 53 | 54 | "LowRes NX" [-option value] [program.nx] 55 | 56 | -fullscreen yes/no 57 | Start the application in fullscreen mode 58 | 59 | -zoom 0-3 60 | Start the application in zoom mode: 0 = pixel perfect, 1 = large, 2 = overscan, 3 = squeeze. 61 | 62 | -disabledev yes/no 63 | Disable the Development Menu, Esc key quits LowRes NX 64 | 65 | -mapping 0-1 66 | Set the key mapping. 0 is standard, 1 is GameShell. 67 | 68 | -disabledelay yes/no 69 | Disable the delay for too short frames. 70 | 71 | program.nx 72 | Name of the program to run 73 | 74 | 75 | ********* 76 | * Notes * 77 | ********* 78 | 79 | - Share programs and discuss on: https://lowresnx.inutilis.com 80 | 81 | - Development news on Twitter: @timo_inutilis 82 | 83 | - Tweet with #LowResNX. 84 | 85 | - To-do and bug list on: 86 | https://github.com/timoinutilis/lowres-nx/issues 87 | 88 | - Write to timo@inutilis.com. 89 | -------------------------------------------------------------------------------- /extras/LowRes NX.sublime-syntax: -------------------------------------------------------------------------------- 1 | %YAML 1.2 2 | --- 3 | # See http://www.sublimetext.com/docs/3/syntax.html 4 | file_extensions: 5 | - nx 6 | name: LowRes NX 7 | scope: source.lowres-nx 8 | contexts: 9 | main: 10 | # Strings 11 | - match: '"' 12 | scope: punctuation.definition.string.begin.lowres-nx 13 | push: double_quoted_string 14 | 15 | # Comments begin with 'REM', # or ' and finish at the end of the line 16 | - match: '^\s*(REM|#|'')' 17 | scope: punctuation.definition.comment.lowres-nx 18 | push: line_comment 19 | 20 | # Keywords 21 | - match: '\b(ABS|ACOS|ADD|ASC|ASIN|ATAN|ATTR|BG|BIN|BUTTON|CALL|CELL\.A|CELL\.C|CELL|CHAR|CHR|CLS|CLW|COLOR|COPY|COS|DATA|DEC|DIM|DISPLAY|DOWN|DO|ELSE|END|ENVELOPE|EXIT|EXP|FILE|FILES|FILL|FONT|FOR|FSIZE|GAMEPAD|GLOBAL|GOSUB|GOTO|HEX|HCOS|HIT|HSIN|HTAN|IF|INC|INKEY|INPUT|INSTR|INT|KEYBOARD|LEFT|LEN|LET|LFO\.A|LFO|LOAD|LOCATE|LOG|LOOP|MAX|MID|MIN|NEXT|NUMBER|OFF|ON|PALETTE|PAUSE|PEEK|PEEKL|PEEKW|PI|PLAY|POKE|POKEL|POKEW|PRINT|RANDOMIZE|RASTER|READ|REPEAT|RESTORE|RETURN|RIGHT|RND|ROL|ROM|ROR|SAVE|SCROLL\.X|SCROLL\.Y|SCROLL|SGN|SIN|SIZE|SOUND|SOURCE|SPRITE\.A|SPRITE\.C|SPRITE\.X|SPRITE\.Y|SPRITE|SQR|STEP|STOP|STR|SUB|SWAP|SYSTEM|TAN|TAP|TEXT|THEN|TIMER|TO|TOUCH\.X|TOUCH\.Y|TOUCH|TRACE|UNTIL|UP|VAL|VBL|VOLUME|WAIT|WEND|WHILE|WINDOW|PAL|FLIP|PRIO|VIEW|WAVE)\b' 22 | scope: keyword.control.lowres-nx 23 | 24 | # Numbers 25 | - match: '\b(-)?[0-9.]+\b' 26 | scope: constant.numeric.lowres-nx 27 | 28 | # Operators 29 | - match: '\b(AND|OR|XOR|NOT|MOD)\b' 30 | scope: keyword.operator.word.lowres-nx 31 | - match: <\=|>\=|\=|<|>|<> 32 | scope: keyword.operator.comparison.lowres-nx 33 | - match: \+|\-|\*|/|\\ 34 | scope: keyword.operator.arithmetic.lowres-nx 35 | 36 | # Punctuation 37 | - match: ',' 38 | scope: punctuation.separator.lowres-nx 39 | 40 | double_quoted_string: 41 | - meta_scope: string.quoted.double.lowres-nx 42 | - match: '\\.' 43 | scope: constant.character.escape.lowres-nx 44 | - match: '"' 45 | scope: punctuation.definition.string.end.lowres-nx 46 | pop: true 47 | 48 | line_comment: 49 | - meta_scope: comment.line.lowres-nx 50 | - match: $ 51 | pop: true 52 | -------------------------------------------------------------------------------- /libretro/libretro_main.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright 2021 Timo Kloss, Antoine Fauroux 3 | // 4 | // This software is provided 'as-is', without any express or implied 5 | // warranty. In no event will the authors be held liable for any damages 6 | // arising from the use of this software. 7 | // 8 | // Permission is granted to anyone to use this software for any purpose, 9 | // including commercial applications, and to alter it and redistribute it 10 | // freely, subject to the following restrictions: 11 | // 12 | // 1. The origin of this software must not be misrepresented; you must not 13 | // claim that you wrote the original software. If you use this software 14 | // in a product, an acknowledgment in the product documentation would be 15 | // appreciated but is not required. 16 | // 2. Altered source versions must be plainly marked as such, and must not be 17 | // misrepresented as being the original software. 18 | // 3. This notice may not be removed or altered from any source distribution. 19 | // 20 | 21 | #ifndef libretro_main_h 22 | #define libretro_main_h 23 | 24 | #include 25 | 26 | enum MainState { 27 | MainStateUndefined, 28 | MainStateBootIntro, 29 | MainStateRunningProgram 30 | }; 31 | 32 | #endif /* libretro_main_h */ 33 | -------------------------------------------------------------------------------- /platform/GameShell/README.md: -------------------------------------------------------------------------------- 1 | # ClockworkPi GameShell 2 | 3 | Compile the Linux version and copy it to /home/cpi/apps. 4 | Copy this folder to the GameShell to add LowRes NX to your menu. 5 | -------------------------------------------------------------------------------- /platform/GameShell/home/cpi/apps/Menu/55_LowRes NX/LowRes NX.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timoinutilis/lowres-nx/85c80181d26bb5c2147ebc76bfc48bce9f8d73a8/platform/GameShell/home/cpi/apps/Menu/55_LowRes NX/LowRes NX.png -------------------------------------------------------------------------------- /platform/GameShell/home/cpi/apps/Menu/55_LowRes NX/action.config: -------------------------------------------------------------------------------- 1 | ROM=/home/cpi/games/LowResNX 2 | EXT=nx 3 | LAUNCHER=/home/cpi/apps/LowResNX -disabledev yes -fullscreen yes -zoom 3 -mapping 1 -disabledelay yes 4 | TITLE=LowRes NX Games 5 | -------------------------------------------------------------------------------- /platform/LibRetro/Makefile.common: -------------------------------------------------------------------------------- 1 | 2 | INCFLAGS := -I ../../core \ 3 | -I ../../core/machine \ 4 | -I ../../core/accessories \ 5 | -I ../../core/datamanager \ 6 | -I ../../core/interpreter \ 7 | -I ../../core/libraries \ 8 | -I ../../core/overlay 9 | 10 | COREDEFINES = -D__LIBRETRO__ 11 | 12 | ifneq (,$(findstring msvc,$(platform))) 13 | COREDEFINES += -DINLINE=_inline 14 | else 15 | COREDEFINES += -DINLINE=inline 16 | endif 17 | 18 | ifeq ($(PSS_STYLE),2) 19 | COREDEFINES += -DPSS_STYLE=2 20 | else 21 | COREDEFINES += -DPSS_STYLE=1 22 | endif 23 | 24 | # Add C sourcecode files to this 25 | SOURCES_C := $(wildcard ../../core/*.c)\ 26 | $(wildcard ../../core/*/*.c)\ 27 | $(wildcard ../../libretro/*.c) 28 | 29 | # Add C++ sourcecode files to this 30 | SOURCES_CXX := -------------------------------------------------------------------------------- /platform/LibRetro/jni/Android.mk: -------------------------------------------------------------------------------- 1 | LOCAL_PATH := $(call my-dir) 2 | 3 | SRCDIR := $(LOCAL_PATH)/../../../ 4 | 5 | INCFLAGS := -I $(SRCDIR)/core \ 6 | -I $(SRCDIR)/core/machine \ 7 | -I $(SRCDIR)/core/accessories \ 8 | -I $(SRCDIR)/core/datamanager \ 9 | -I $(SRCDIR)/core/interpreter \ 10 | -I $(SRCDIR)/core/libraries \ 11 | -I $(SRCDIR)/core/overlay 12 | 13 | COREFLAGS := -fomit-frame-pointer -ffast-math -D__LIBRETRO__ $(INCFLAGS) 14 | COREFLAGS += -DGB_INTERNAL -DDISABLE_DEBUGGER -DPLATFORM_ANDROID 15 | 16 | GIT_VERSION := " $(shell git rev-parse --short HEAD || echo unknown)" 17 | ifneq ($(GIT_VERSION)," unknown") 18 | COREFLAGS += -DGIT_VERSION=\"$(GIT_VERSION)\" 19 | endif 20 | 21 | SRCFILES := $(wildcard $(SRCDIR)/core/*.c)\ 22 | $(wildcard $(SRCDIR)/core/*/*.c)\ 23 | $(wildcard $(SRCDIR)/libretro/*.c) 24 | 25 | include $(CLEAR_VARS) 26 | LOCAL_MODULE := retro 27 | LOCAL_SRC_FILES := $(SRCFILES) 28 | LOCAL_CPPFLAGS := -std=c++17 $(COREFLAGS) 29 | LOCAL_CFLAGS := $(COREFLAGS) 30 | LOCAL_LDFLAGS := -Wl,-version-script=../link.T 31 | LOCAL_CPP_FEATURES := exceptions rtti 32 | include $(BUILD_SHARED_LIBRARY) -------------------------------------------------------------------------------- /platform/LibRetro/jni/Application.mk: -------------------------------------------------------------------------------- 1 | APP_ABI := all 2 | APP_STL := c++_static -------------------------------------------------------------------------------- /platform/LibRetro/link.T: -------------------------------------------------------------------------------- 1 | { 2 | global: retro_*; 3 | local: *; 4 | }; 5 | -------------------------------------------------------------------------------- /platform/Linux/README.md: -------------------------------------------------------------------------------- 1 | Build for LINUX 2 | =============== 3 | 4 | ## Installing Dependencies 5 | 6 | ### Ubuntu 7 | > Tested with Ubuntu 18.04 8 | 9 | ```bash 10 | sudo apt install git make build-essential libsdl2-dev 11 | ``` 12 | 13 | ### Debian 14 | > Tested with Debian 11 (Bullseye) 15 | 16 | ```bash 17 | sudo apt install git make build-essential libsdl2-dev libdrm-dev libgbm-dev 18 | ``` 19 | 20 | ### Arch Linux 21 | > Tested with Arch Linux (x86_64, kernel version 6.9.3-arch1-1) 22 | 23 | ```bash 24 | sudo pacman -S git make base-devel sdl2 25 | ``` 26 | 27 | ## Building and Running 28 | These steps have been tested on all the distributions listed above and work without modification. 29 | ```bash 30 | git clone https://github.com/timoinutilis/lowres-nx.git 31 | cd lowres-nx/platform/Linux/ 32 | make 33 | ./output/LowResNX 34 | ``` 35 | -------------------------------------------------------------------------------- /platform/Linux/makefile: -------------------------------------------------------------------------------- 1 | # Declaration of variables 2 | CC = gcc 3 | CC_FLAGS = -D __LINUX__ -w -I ../../core -I ../../core/machine -I ../../core/accessories -I ../../core/datamanager -I ../../core/interpreter -I ../../core/libraries -I ../../core/overlay -lSDL2main -lSDL2 -lm 4 | CC_FLAGS_MAIN = -D __LINUX__ -lSDL2main -lSDL2 -lm `sdl2-config --cflags --static-libs` 5 | 6 | # File names 7 | EXEC = output/LowResNX 8 | SOURCES = $(wildcard ../../core/*.c) $(wildcard ../../core/*/*.c) $(wildcard ../../sdl/*.c) 9 | OBJECTS = $(SOURCES:.c=.bc) 10 | 11 | # Main target 12 | $(EXEC): $(OBJECTS) 13 | @mkdir -p $(@D) 14 | $(CC) $(OBJECTS) -o $(EXEC) $(CC_FLAGS_MAIN) 15 | 16 | # To obtain object files 17 | %.bc: %.c 18 | $(CC) -c $(CC_FLAGS) $< -o $@ 19 | 20 | # To remove generated files 21 | clean: 22 | rm -f $(OBJECTS) 23 | -------------------------------------------------------------------------------- /platform/Windows/LowRes NX Win.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 15 4 | VisualStudioVersion = 15.0.27703.2035 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "LowRes NX Win", "LowRes NX Win\LowRes NX Win.vcxproj", "{5F65EDCE-D405-4962-BD3B-65C49E160B3E}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|x64 = Debug|x64 11 | Debug|x86 = Debug|x86 12 | Release|x64 = Release|x64 13 | Release|x86 = Release|x86 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {5F65EDCE-D405-4962-BD3B-65C49E160B3E}.Debug|x64.ActiveCfg = Debug|x64 17 | {5F65EDCE-D405-4962-BD3B-65C49E160B3E}.Debug|x64.Build.0 = Debug|x64 18 | {5F65EDCE-D405-4962-BD3B-65C49E160B3E}.Debug|x86.ActiveCfg = Debug|Win32 19 | {5F65EDCE-D405-4962-BD3B-65C49E160B3E}.Debug|x86.Build.0 = Debug|Win32 20 | {5F65EDCE-D405-4962-BD3B-65C49E160B3E}.Release|x64.ActiveCfg = Release|x64 21 | {5F65EDCE-D405-4962-BD3B-65C49E160B3E}.Release|x64.Build.0 = Release|x64 22 | {5F65EDCE-D405-4962-BD3B-65C49E160B3E}.Release|x86.ActiveCfg = Release|Win32 23 | {5F65EDCE-D405-4962-BD3B-65C49E160B3E}.Release|x86.Build.0 = Release|Win32 24 | EndGlobalSection 25 | GlobalSection(SolutionProperties) = preSolution 26 | HideSolutionNode = FALSE 27 | EndGlobalSection 28 | GlobalSection(ExtensibilityGlobals) = postSolution 29 | SolutionGuid = {13C7A20F-9918-41F2-B5D1-CCE0C942A3EC} 30 | EndGlobalSection 31 | EndGlobal 32 | -------------------------------------------------------------------------------- /platform/Windows/LowRes NX Win/LowRes NX Win.rc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timoinutilis/lowres-nx/85c80181d26bb5c2147ebc76bfc48bce9f8d73a8/platform/Windows/LowRes NX Win/LowRes NX Win.rc -------------------------------------------------------------------------------- /platform/Windows/LowRes NX Win/icon1.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timoinutilis/lowres-nx/85c80181d26bb5c2147ebc76bfc48bce9f8d73a8/platform/Windows/LowRes NX Win/icon1.ico -------------------------------------------------------------------------------- /platform/Windows/LowRes NX Win/resource.h: -------------------------------------------------------------------------------- 1 | //{{NO_DEPENDENCIES}} 2 | // Microsoft Visual C++ generated include file. 3 | // Used by LowRes NX Win.rc 4 | // 5 | #define IDI_ICON1 101 6 | 7 | // Next default values for new objects 8 | // 9 | #ifdef APSTUDIO_INVOKED 10 | #ifndef APSTUDIO_READONLY_SYMBOLS 11 | #define _APS_NEXT_RESOURCE_VALUE 102 12 | #define _APS_NEXT_COMMAND_VALUE 40001 13 | #define _APS_NEXT_CONTROL_VALUE 1001 14 | #define _APS_NEXT_SYMED_VALUE 101 15 | #endif 16 | #endif 17 | -------------------------------------------------------------------------------- /platform/Windows/LowRes NX Win/resource1.h: -------------------------------------------------------------------------------- 1 | //{{NO_DEPENDENCIES}} 2 | // Microsoft Visual C++ generated include file. 3 | // Used by LowRes NX Win.rc 4 | // 5 | #define IDI_ICON1 101 6 | 7 | // Next default values for new objects 8 | // 9 | #ifdef APSTUDIO_INVOKED 10 | #ifndef APSTUDIO_READONLY_SYMBOLS 11 | #define _APS_NEXT_RESOURCE_VALUE 103 12 | #define _APS_NEXT_COMMAND_VALUE 40001 13 | #define _APS_NEXT_CONTROL_VALUE 1001 14 | #define _APS_NEXT_SYMED_VALUE 101 15 | #endif 16 | #endif 17 | -------------------------------------------------------------------------------- /platform/Windows/assets/App Icon 16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timoinutilis/lowres-nx/85c80181d26bb5c2147ebc76bfc48bce9f8d73a8/platform/Windows/assets/App Icon 16.png -------------------------------------------------------------------------------- /platform/Windows/assets/App Icon 256.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timoinutilis/lowres-nx/85c80181d26bb5c2147ebc76bfc48bce9f8d73a8/platform/Windows/assets/App Icon 256.png -------------------------------------------------------------------------------- /platform/Windows/assets/App Icon 32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timoinutilis/lowres-nx/85c80181d26bb5c2147ebc76bfc48bce9f8d73a8/platform/Windows/assets/App Icon 32.png -------------------------------------------------------------------------------- /platform/Windows/assets/App Icon 48.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timoinutilis/lowres-nx/85c80181d26bb5c2147ebc76bfc48bce9f8d73a8/platform/Windows/assets/App Icon 48.png -------------------------------------------------------------------------------- /platform/Windows/assets/lowresnx.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timoinutilis/lowres-nx/85c80181d26bb5c2147ebc76bfc48bce9f8d73a8/platform/Windows/assets/lowresnx.ico -------------------------------------------------------------------------------- /platform/iOS/LowRes NX iOS.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /platform/iOS/LowRes NX iOS.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /platform/iOS/LowRes NX iOS/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // LowRes NX iOS 4 | // 5 | // Created by Timo Kloss on 1/9/17. 6 | // Copyright © 2017 Inutilis Software. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | @UIApplicationMain 12 | class AppDelegate: UIResponder, UIApplicationDelegate { 13 | 14 | var window: UIWindow? 15 | 16 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { 17 | 18 | return true 19 | } 20 | 21 | func applicationWillResignActive(_ application: UIApplication) { 22 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 23 | // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game. 24 | } 25 | 26 | func applicationDidEnterBackground(_ application: UIApplication) { 27 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 28 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 29 | } 30 | 31 | func applicationWillEnterForeground(_ application: UIApplication) { 32 | // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background. 33 | } 34 | 35 | func applicationDidBecomeActive(_ application: UIApplication) { 36 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 37 | } 38 | 39 | func applicationWillTerminate(_ application: UIApplication) { 40 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 41 | } 42 | 43 | 44 | } 45 | 46 | -------------------------------------------------------------------------------- /platform/iOS/LowRes NX iOS/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "20x20", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "20x20", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "29x29", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "29x29", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "40x40", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "40x40", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "idiom" : "iphone", 35 | "size" : "60x60", 36 | "scale" : "2x" 37 | }, 38 | { 39 | "idiom" : "iphone", 40 | "size" : "60x60", 41 | "scale" : "3x" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "size" : "20x20", 46 | "scale" : "1x" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "size" : "20x20", 51 | "scale" : "2x" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "size" : "29x29", 56 | "scale" : "1x" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "size" : "29x29", 61 | "scale" : "2x" 62 | }, 63 | { 64 | "idiom" : "ipad", 65 | "size" : "40x40", 66 | "scale" : "1x" 67 | }, 68 | { 69 | "idiom" : "ipad", 70 | "size" : "40x40", 71 | "scale" : "2x" 72 | }, 73 | { 74 | "idiom" : "ipad", 75 | "size" : "76x76", 76 | "scale" : "1x" 77 | }, 78 | { 79 | "idiom" : "ipad", 80 | "size" : "76x76", 81 | "scale" : "2x" 82 | }, 83 | { 84 | "idiom" : "ipad", 85 | "size" : "83.5x83.5", 86 | "scale" : "2x" 87 | } 88 | ], 89 | "info" : { 90 | "version" : 1, 91 | "author" : "xcode" 92 | } 93 | } -------------------------------------------------------------------------------- /platform/iOS/LowRes NX iOS/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /platform/iOS/LowRes NX iOS/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /platform/iOS/LowRes NX iOS/CoreWrapper.swift: -------------------------------------------------------------------------------- 1 | // 2 | // CoreWrapper.swift 3 | // LowRes NX iOS 4 | // 5 | // Created by Timo Kloss on 2/9/17. 6 | // Copyright © 2017 Inutilis Software. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | protocol CoreWrapperDelegate: class { 12 | func coreInterpreterDidFail(coreError: CoreError) -> Void 13 | func coreDiskDriveWillAccess(diskDataManager: UnsafeMutablePointer?) -> Bool 14 | func coreDiskDriveDidSave(diskDataManager: UnsafeMutablePointer?) -> Void 15 | func coreControlsDidChange(controlsInfo: ControlsInfo) -> Void 16 | } 17 | 18 | class CoreWrapper: NSObject { 19 | 20 | weak var delegate: CoreWrapperDelegate? 21 | 22 | var core = Core() 23 | private var coreDelegate = CoreDelegate() 24 | 25 | override init() { 26 | super.init() 27 | core_init(&core) 28 | 29 | coreDelegate.context = UnsafeMutableRawPointer(Unmanaged.passUnretained(self).toOpaque()) 30 | coreDelegate.interpreterDidFail = interpreterDidFail 31 | coreDelegate.diskDriveWillAccess = diskDriveWillAccess 32 | coreDelegate.diskDriveDidSave = diskDriveDidSave 33 | coreDelegate.controlsDidChange = controlsDidChange 34 | core_setDelegate(&core, &coreDelegate) 35 | } 36 | 37 | deinit { 38 | core_deinit(&core) 39 | } 40 | 41 | } 42 | 43 | class LowResNXError: NSError { 44 | 45 | let coreError: CoreError 46 | 47 | init(error: CoreError, sourceCode: String) { 48 | coreError = error 49 | let index = sourceCode.index(sourceCode.startIndex, offsetBy: String.IndexDistance(error.sourcePosition)) 50 | let lineRange = sourceCode.lineRange(for: index ..< index) 51 | let lineString = sourceCode[lineRange].trimmingCharacters(in: CharacterSet.whitespaces) 52 | let lineNumber = sourceCode.countLines(index: index) 53 | 54 | let errorString = String(cString:err_getString(error.code)) 55 | let errorText = "Error in line \(lineNumber): \(errorString)\n\(lineString)" 56 | super.init(domain: "LowResNX", code: Int(error.code.rawValue), userInfo: [NSLocalizedDescriptionKey: errorText]) 57 | } 58 | 59 | required init?(coder aDecoder: NSCoder) { 60 | fatalError("init(coder:) has not been implemented") 61 | } 62 | 63 | } 64 | 65 | extension String { 66 | 67 | func countLines(index: String.Index) -> Int { 68 | var count = 1 69 | var searchRange = startIndex ..< endIndex 70 | while let foundRange = rangeOfCharacter(from: CharacterSet.newlines, options: .literal, range: searchRange), index >= foundRange.upperBound { 71 | searchRange = characters.index(after: foundRange.lowerBound) ..< endIndex 72 | count += 1 73 | } 74 | return count; 75 | } 76 | 77 | } 78 | 79 | //MARK: - Core Delegate Functions Wrapper 80 | 81 | func interpreterDidFail(context: UnsafeMutableRawPointer?, coreError: CoreError) -> Void { 82 | let wrapper = Unmanaged.fromOpaque(context!).takeUnretainedValue() 83 | wrapper.delegate?.coreInterpreterDidFail(coreError: coreError) 84 | } 85 | 86 | func diskDriveWillAccess(context: UnsafeMutableRawPointer?, diskDataManager: UnsafeMutablePointer?) -> Bool { 87 | let wrapper = Unmanaged.fromOpaque(context!).takeUnretainedValue() 88 | return wrapper.delegate?.coreDiskDriveWillAccess(diskDataManager: diskDataManager) ?? true 89 | } 90 | 91 | func diskDriveDidSave(context: UnsafeMutableRawPointer?, diskDataManager: UnsafeMutablePointer?) -> Void { 92 | let wrapper = Unmanaged.fromOpaque(context!).takeUnretainedValue() 93 | wrapper.delegate?.coreDiskDriveDidSave(diskDataManager: diskDataManager) 94 | } 95 | 96 | func controlsDidChange(context: UnsafeMutableRawPointer?, controlsInfo: ControlsInfo) -> Void { 97 | let wrapper = Unmanaged.fromOpaque(context!).takeUnretainedValue() 98 | wrapper.delegate?.coreControlsDidChange(controlsInfo: controlsInfo) 99 | } 100 | -------------------------------------------------------------------------------- /platform/iOS/LowRes NX iOS/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 0.1 19 | CFBundleVersion 20 | 1 21 | LSRequiresIPhoneOS 22 | 23 | UILaunchStoryboardName 24 | LaunchScreen 25 | UIMainStoryboardFile 26 | Main 27 | UIRequiredDeviceCapabilities 28 | 29 | armv7 30 | 31 | UIStatusBarHidden 32 | 33 | UIStatusBarStyle 34 | UIStatusBarStyleDefault 35 | UISupportedInterfaceOrientations 36 | 37 | UIInterfaceOrientationPortrait 38 | UIInterfaceOrientationLandscapeLeft 39 | UIInterfaceOrientationLandscapeRight 40 | UIInterfaceOrientationPortraitUpsideDown 41 | 42 | UISupportedInterfaceOrientations~ipad 43 | 44 | UIInterfaceOrientationPortrait 45 | UIInterfaceOrientationPortraitUpsideDown 46 | UIInterfaceOrientationLandscapeLeft 47 | UIInterfaceOrientationLandscapeRight 48 | 49 | 50 | 51 | -------------------------------------------------------------------------------- /platform/iOS/LowRes NX iOS/LowResNX-Bridging-Header.h: -------------------------------------------------------------------------------- 1 | // 2 | // LowResNX-Bridging-Header.h 3 | // LowRes NX iOS 4 | // 5 | // Created by Timo Kloss on 23/4/17. 6 | // Copyright © 2017 Inutilis Software. All rights reserved. 7 | // 8 | 9 | #include "core.h" 10 | -------------------------------------------------------------------------------- /platform/iOS/LowRes NX iOS/LowResNXView.swift: -------------------------------------------------------------------------------- 1 | // 2 | // LowResNXView.swift 3 | // LowRes NX iOS 4 | // 5 | // Created by Timo Kloss on 1/9/17. 6 | // Copyright © 2017 Inutilis Software. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class LowResNXView: UIView { 12 | var coreWrapper: CoreWrapper? 13 | 14 | private var data: UnsafeMutablePointer? 15 | private var dataProvider: CGDataProvider? 16 | 17 | required init?(coder aDecoder: NSCoder) { 18 | super.init(coder: aDecoder) 19 | 20 | let dataLength = Int(SCREEN_WIDTH) * Int(SCREEN_HEIGHT) * 4; 21 | data = UnsafeMutablePointer.allocate(capacity: dataLength) 22 | var callbacks = CGDataProviderDirectCallbacks(version: 0, getBytePointer: getBytePointerCallback, releaseBytePointer: nil, getBytesAtPosition: nil, releaseInfo: nil) 23 | dataProvider = CGDataProvider(directInfo: data, size: off_t(dataLength), callbacks: &callbacks) 24 | } 25 | 26 | override func awakeFromNib() { 27 | super.awakeFromNib() 28 | isMultipleTouchEnabled = true 29 | } 30 | 31 | func render() { 32 | if let coreWrapper = coreWrapper, let dataProvider = dataProvider { 33 | video_renderScreen(&coreWrapper.core, data, SCREEN_WIDTH*4) 34 | let image = CGImage(width: Int(SCREEN_WIDTH), height: Int(SCREEN_HEIGHT), bitsPerComponent: 8, bitsPerPixel: 32, bytesPerRow: Int(SCREEN_WIDTH)*4, space: CGColorSpaceCreateDeviceRGB(), bitmapInfo: CGBitmapInfo(rawValue: CGImageAlphaInfo.noneSkipLast.rawValue), provider: dataProvider, decode: nil, shouldInterpolate: false, intent: .defaultIntent) 35 | 36 | layer.contents = image 37 | layer.magnificationFilter = kCAFilterNearest 38 | } 39 | } 40 | 41 | override func touchesBegan(_ touches: Set, with event: UIEvent?) { 42 | if let coreWrapper = coreWrapper { 43 | for touch in touches { 44 | let point = screenPoint(touch: touch) 45 | core_touchPressed(&coreWrapper.core, Int32(point.x), Int32(point.y), Unmanaged.passUnretained(touch).toOpaque()) 46 | } 47 | } 48 | } 49 | 50 | override func touchesMoved(_ touches: Set, with event: UIEvent?) { 51 | if let coreWrapper = coreWrapper { 52 | for touch in touches { 53 | let point = screenPoint(touch: touch) 54 | core_touchDragged(&coreWrapper.core, Int32(point.x), Int32(point.y), Unmanaged.passUnretained(touch).toOpaque()) 55 | } 56 | } 57 | } 58 | 59 | override func touchesEnded(_ touches: Set, with event: UIEvent?) { 60 | if let coreWrapper = coreWrapper { 61 | for touch in touches { 62 | core_touchReleased(&coreWrapper.core, Unmanaged.passUnretained(touch).toOpaque()) 63 | } 64 | } 65 | } 66 | 67 | override func touchesCancelled(_ touches: Set, with event: UIEvent?) { 68 | if let coreWrapper = coreWrapper { 69 | for touch in touches { 70 | core_touchReleased(&coreWrapper.core, Unmanaged.passUnretained(touch).toOpaque()) 71 | } 72 | } 73 | } 74 | 75 | private func screenPoint(touch: UITouch) -> CGPoint { 76 | let viewPoint = touch.location(in: self) 77 | let x = viewPoint.x * CGFloat(SCREEN_WIDTH) / bounds.size.width; 78 | let y = viewPoint.y * CGFloat(SCREEN_HEIGHT) / bounds.size.height; 79 | return CGPoint(x: x, y: y); 80 | } 81 | 82 | } 83 | 84 | func getBytePointerCallback(_ data: UnsafeMutableRawPointer?) -> UnsafeRawPointer? { 85 | return UnsafeRawPointer(data) 86 | } 87 | -------------------------------------------------------------------------------- /platform/macOS/LowRes NX macOS.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /platform/macOS/LowRes NX macOS.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /platform/macOS/LowRes NX macOS/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "size" : "16x16", 5 | "idiom" : "mac", 6 | "filename" : "Mac App Icon 16.png", 7 | "scale" : "1x" 8 | }, 9 | { 10 | "size" : "16x16", 11 | "idiom" : "mac", 12 | "filename" : "Mac App Icon 16@2x.png", 13 | "scale" : "2x" 14 | }, 15 | { 16 | "size" : "32x32", 17 | "idiom" : "mac", 18 | "filename" : "Mac App Icon 32.png", 19 | "scale" : "1x" 20 | }, 21 | { 22 | "size" : "32x32", 23 | "idiom" : "mac", 24 | "filename" : "Mac App Icon 64.png", 25 | "scale" : "2x" 26 | }, 27 | { 28 | "size" : "128x128", 29 | "idiom" : "mac", 30 | "filename" : "Mac App Icon 128.png", 31 | "scale" : "1x" 32 | }, 33 | { 34 | "size" : "128x128", 35 | "idiom" : "mac", 36 | "filename" : "Mac App Icon 256-1.png", 37 | "scale" : "2x" 38 | }, 39 | { 40 | "size" : "256x256", 41 | "idiom" : "mac", 42 | "filename" : "Mac App Icon 256.png", 43 | "scale" : "1x" 44 | }, 45 | { 46 | "size" : "256x256", 47 | "idiom" : "mac", 48 | "filename" : "Mac App Icon 512-1.png", 49 | "scale" : "2x" 50 | }, 51 | { 52 | "size" : "512x512", 53 | "idiom" : "mac", 54 | "filename" : "Mac App Icon 512.png", 55 | "scale" : "1x" 56 | }, 57 | { 58 | "size" : "512x512", 59 | "idiom" : "mac", 60 | "filename" : "Mac App Icon 512@2x.png", 61 | "scale" : "2x" 62 | } 63 | ], 64 | "info" : { 65 | "version" : 1, 66 | "author" : "xcode" 67 | } 68 | } -------------------------------------------------------------------------------- /platform/macOS/LowRes NX macOS/Assets.xcassets/AppIcon.appiconset/Mac App Icon 128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timoinutilis/lowres-nx/85c80181d26bb5c2147ebc76bfc48bce9f8d73a8/platform/macOS/LowRes NX macOS/Assets.xcassets/AppIcon.appiconset/Mac App Icon 128.png -------------------------------------------------------------------------------- /platform/macOS/LowRes NX macOS/Assets.xcassets/AppIcon.appiconset/Mac App Icon 16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timoinutilis/lowres-nx/85c80181d26bb5c2147ebc76bfc48bce9f8d73a8/platform/macOS/LowRes NX macOS/Assets.xcassets/AppIcon.appiconset/Mac App Icon 16.png -------------------------------------------------------------------------------- /platform/macOS/LowRes NX macOS/Assets.xcassets/AppIcon.appiconset/Mac App Icon 16@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timoinutilis/lowres-nx/85c80181d26bb5c2147ebc76bfc48bce9f8d73a8/platform/macOS/LowRes NX macOS/Assets.xcassets/AppIcon.appiconset/Mac App Icon 16@2x.png -------------------------------------------------------------------------------- /platform/macOS/LowRes NX macOS/Assets.xcassets/AppIcon.appiconset/Mac App Icon 256-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timoinutilis/lowres-nx/85c80181d26bb5c2147ebc76bfc48bce9f8d73a8/platform/macOS/LowRes NX macOS/Assets.xcassets/AppIcon.appiconset/Mac App Icon 256-1.png -------------------------------------------------------------------------------- /platform/macOS/LowRes NX macOS/Assets.xcassets/AppIcon.appiconset/Mac App Icon 256.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timoinutilis/lowres-nx/85c80181d26bb5c2147ebc76bfc48bce9f8d73a8/platform/macOS/LowRes NX macOS/Assets.xcassets/AppIcon.appiconset/Mac App Icon 256.png -------------------------------------------------------------------------------- /platform/macOS/LowRes NX macOS/Assets.xcassets/AppIcon.appiconset/Mac App Icon 32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timoinutilis/lowres-nx/85c80181d26bb5c2147ebc76bfc48bce9f8d73a8/platform/macOS/LowRes NX macOS/Assets.xcassets/AppIcon.appiconset/Mac App Icon 32.png -------------------------------------------------------------------------------- /platform/macOS/LowRes NX macOS/Assets.xcassets/AppIcon.appiconset/Mac App Icon 512-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timoinutilis/lowres-nx/85c80181d26bb5c2147ebc76bfc48bce9f8d73a8/platform/macOS/LowRes NX macOS/Assets.xcassets/AppIcon.appiconset/Mac App Icon 512-1.png -------------------------------------------------------------------------------- /platform/macOS/LowRes NX macOS/Assets.xcassets/AppIcon.appiconset/Mac App Icon 512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timoinutilis/lowres-nx/85c80181d26bb5c2147ebc76bfc48bce9f8d73a8/platform/macOS/LowRes NX macOS/Assets.xcassets/AppIcon.appiconset/Mac App Icon 512.png -------------------------------------------------------------------------------- /platform/macOS/LowRes NX macOS/Assets.xcassets/AppIcon.appiconset/Mac App Icon 512@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timoinutilis/lowres-nx/85c80181d26bb5c2147ebc76bfc48bce9f8d73a8/platform/macOS/LowRes NX macOS/Assets.xcassets/AppIcon.appiconset/Mac App Icon 512@2x.png -------------------------------------------------------------------------------- /platform/macOS/LowRes NX macOS/Assets.xcassets/AppIcon.appiconset/Mac App Icon 64.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timoinutilis/lowres-nx/85c80181d26bb5c2147ebc76bfc48bce9f8d73a8/platform/macOS/LowRes NX macOS/Assets.xcassets/AppIcon.appiconset/Mac App Icon 64.png -------------------------------------------------------------------------------- /platform/macOS/LowRes NX macOS/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /platform/macOS/LowRes NX macOS/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleDocumentTypes 8 | 9 | 10 | CFBundleTypeExtensions 11 | 12 | nx 13 | 14 | CFBundleTypeName 15 | LowRes NX Program 16 | CFBundleTypeRole 17 | Editor 18 | LSTypeIsPackage 19 | 0 20 | 21 | 22 | CFBundleExecutable 23 | $(EXECUTABLE_NAME) 24 | CFBundleIconFile 25 | 26 | CFBundleIdentifier 27 | $(PRODUCT_BUNDLE_IDENTIFIER) 28 | CFBundleInfoDictionaryVersion 29 | 6.0 30 | CFBundleName 31 | $(PRODUCT_NAME) 32 | CFBundlePackageType 33 | APPL 34 | CFBundleShortVersionString 35 | $(MARKETING_VERSION) 36 | CFBundleVersion 37 | $(CURRENT_PROJECT_VERSION) 38 | LSMinimumSystemVersion 39 | $(MACOSX_DEPLOYMENT_TARGET) 40 | NSHumanReadableCopyright 41 | Copyright © 2017-2021 Timo Kloss. 42 | This program is released under the zlib License. 43 | NSPrincipalClass 44 | NSApplication 45 | SDL_FILESYSTEM_BASE_DIR_TYPE 46 | parent 47 | 48 | 49 | -------------------------------------------------------------------------------- /platform/macOS/LowRes NX macOS/LowRes_NX_macOS_SDL.entitlements: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /platform/web/README.md: -------------------------------------------------------------------------------- 1 | These lines are interesting, but still not a real guide for compiling: 2 | 3 | source ./emsdk_env.sh 4 | emmake make 5 | 6 | Always clean before build, otherwise changed files will be ignored! 7 | emmake make clean -------------------------------------------------------------------------------- /platform/web/embed/package/LowResNX120.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timoinutilis/lowres-nx/85c80181d26bb5c2147ebc76bfc48bce9f8d73a8/platform/web/embed/package/LowResNX120.wasm -------------------------------------------------------------------------------- /platform/web/embed/package/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | LowRes NX 8 | 21 | 22 | 23 |
24 | 25 |
26 | 27 | 46 | 47 | 48 | 49 | -------------------------------------------------------------------------------- /platform/web/embed/package/program.nx: -------------------------------------------------------------------------------- 1 | PRINT "REPLACE THIS WITH" 2 | PRINT "YOUR PROGRAM" 3 | -------------------------------------------------------------------------------- /platform/web/embed/readme.txt: -------------------------------------------------------------------------------- 1 | Embeddable Web Player for LowRes NX 2 | 3 | Replace the file "program.nx" in the "package" folder with your own program. It must be called "program.nx". You should rename the folder to your program's name. 4 | 5 | How to publish it on itch.io 6 | 7 | Make a zip archive of your folder and upload it to itch.io. Select "This file will be played in the browser" and set the viewport dimensions to 640x512. Please add the tag "lowres-nx". You may choose "Automatically start on page load", or if not, upload a screenshot for "Embed BG" in the theme editor. -------------------------------------------------------------------------------- /platform/web/makefile: -------------------------------------------------------------------------------- 1 | # Declaration of variables 2 | CC = emcc 3 | CC_FLAGS = -w -s USE_SDL=2 -I ../../core -I ../../core/machine -I ../../core/accessories -I ../../core/datamanager -I ../../core/interpreter -I ../../core/libraries -I ../../core/overlay 4 | CC_FLAGS_MAIN = -s USE_SDL=2 5 | 6 | # File names 7 | EXEC = output/LowResNX120.js 8 | SOURCES = $(wildcard ../../core/*.c) $(wildcard ../../core/*/*.c) $(wildcard ../../sdl/*.c) 9 | OBJECTS = $(SOURCES:.c=.bc) 10 | 11 | # Main target 12 | $(EXEC): $(OBJECTS) 13 | @mkdir -p $(@D) 14 | $(CC) $(CC_FLAGS_MAIN) $(OBJECTS) -o $(EXEC) 15 | 16 | # To obtain object files 17 | %.bc: %.c 18 | $(CC) -c $(CC_FLAGS) $< -o $@ 19 | 20 | # To remove generated files 21 | clean: 22 | rm -f $(OBJECTS) -------------------------------------------------------------------------------- /platform/web/output/LowResNX100.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timoinutilis/lowres-nx/85c80181d26bb5c2147ebc76bfc48bce9f8d73a8/platform/web/output/LowResNX100.wasm -------------------------------------------------------------------------------- /platform/web/output/LowResNX110.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timoinutilis/lowres-nx/85c80181d26bb5c2147ebc76bfc48bce9f8d73a8/platform/web/output/LowResNX110.wasm -------------------------------------------------------------------------------- /platform/web/output/LowResNX120.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timoinutilis/lowres-nx/85c80181d26bb5c2147ebc76bfc48bce9f8d73a8/platform/web/output/LowResNX120.wasm -------------------------------------------------------------------------------- /programs test/BG Scroll.nx: -------------------------------------------------------------------------------- 1 | BG COPY 0,0,20,16 TO 0,0 2 | GAMEPAD 1 3 | DO 4 | IF LEFT TAP(0) THEN BG SCROLL 2,2 TO 17,13 STEP -1,0 5 | IF RIGHT TAP(0) THEN BG SCROLL 2,2 TO 17,13 STEP 1,0 6 | IF UP TAP(0) THEN BG SCROLL 2,2 TO 17,13 STEP 0,-1 7 | IF DOWN TAP(0) THEN BG SCROLL 2,2 TO 17,13 STEP 0,1 8 | WAIT VBL 9 | LOOP 10 | 11 | #1:MAIN PALETTES 12 | 053F2F00053834000000000000000000 13 | 00000000000000000000000000000000 14 | 15 | #2:MAIN CHARACTERS 16 | 00000000000000000000000000000000 17 | 81422418182442810000000000000000 18 | FFFFFFFFFFFFFFFF0000000000000000 19 | 0000000000000000FFFFFFFFFFFFFFFF 20 | FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF 21 | 183C42C3C3423C18005A004242005A00 22 | 23 | #3:MAIN BG 24 | 000014100101010100000101000000000000 25 | 01010101010100000101010100000000 26 | 01010000000001010101010100000101 27 | 01010101000001010101010100000101 28 | 00000000010101010000010100000101 29 | 01010000000000000200000002000000 30 | 02000000020000000000000000000000 31 | 00000000030001010000000001010000 32 | 02000000000000000000000002000000 33 | 00000000000000000000000000000101 34 | 01010000000000000200000002000200 35 | 02000000020000000000000003000000 36 | 00000000000001010101010100000000 37 | 03000000000000000000000003000000 38 | 00000000000000000000000000000101 39 | 00000101010100000000030002000200 40 | 02000300000000000000000000000000 41 | 00000200020000000000010101010000 42 | 00000000000000000000000000000000 43 | 02000200000000000200000000000000 44 | 01010000010100000000000000000000 45 | 00000000000002000000000002000200 46 | 00000000000001010000010100000000 47 | 00000301000000000300000000000200 48 | 00000000000002000000000003000000 49 | 01010101000000000000000000000000 50 | 00000000000000000000000000000200 51 | 00000000000001010000000001010000 52 | 04000400040004000000000004000000 53 | 00000000000002000000000004000101 54 | 00000101010104000400040004000400 55 | 04000400040004000000000000000200 56 | 00000000000001010000000001010300 57 | 00000000040004000400040004000400 58 | 04000400000000000000030100000000 59 | 01010101000001010101010100000101 60 | 00000101010101010101010101010000 61 | 00000101010101010101010101010000 62 | 01010101010101010101010101010000 63 | 01010000000001010101010100000101 64 | 0101 65 | 66 | -------------------------------------------------------------------------------- /programs test/Crazy Text.nx: -------------------------------------------------------------------------------- 1 | RANDOMIZE TIMER 2 | 3 | PRINT "++++++++++++++++++++"; 4 | PRINT "...................."; 5 | PRINT "////////////////////"; 6 | PRINT 7 | PRINT " HELLO!" 8 | PRINT " THIS HAPPENDS WHEN" 9 | PRINT " YOU PRINT SOME " 10 | PRINT " TEXT ON SCREEN AND" 11 | PRINT " THEN CHANGE THE" 12 | PRINT " CELL ATTRIBUTES" 13 | PRINT " RANDOMLY." 14 | PRINT 15 | PRINT 16 | PRINT "////////////////////"; 17 | PRINT ".....LOWRES NX....."; 18 | PRINT "++++++++++++++++++++"; 19 | 20 | DO 21 | ATTR (RND*4,RND*2,RND*2,0,0) 22 | BG FILL RND*10,RND*8 TO 10+RND*10,8+RND*8 23 | WAIT 4 24 | LOOP 25 | -------------------------------------------------------------------------------- /programs test/Demo 0.5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timoinutilis/lowres-nx/85c80181d26bb5c2147ebc76bfc48bce9f8d73a8/programs test/Demo 0.5.png -------------------------------------------------------------------------------- /programs test/Files.nx: -------------------------------------------------------------------------------- 1 | FILES 2 | FOR I=0 TO 15 3 | NUMBER 0,I,I,2 4 | TEXT 3,I,FILE$(I) 5 | NEXT I 6 | -------------------------------------------------------------------------------- /programs test/Scrolling Map 0.3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timoinutilis/lowres-nx/85c80181d26bb5c2147ebc76bfc48bce9f8d73a8/programs test/Scrolling Map 0.3.png -------------------------------------------------------------------------------- /programs test/Slide Show 0.4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timoinutilis/lowres-nx/85c80181d26bb5c2147ebc76bfc48bce9f8d73a8/programs test/Slide Show 0.4.png -------------------------------------------------------------------------------- /programs test/Sprites with Background 0.3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timoinutilis/lowres-nx/85c80181d26bb5c2147ebc76bfc48bce9f8d73a8/programs test/Sprites with Background 0.3.png -------------------------------------------------------------------------------- /programs test/Subs 1.nx: -------------------------------------------------------------------------------- 1 | CALL HELLO 2 | CALL GREET("LOWRES",3) 3 | 4 | NUM=10 5 | CALL INCR(NUM,10) 6 | PRINT NUM 7 | 8 | DIM ARR(10) 9 | 10 | ARR(2)=5 11 | CALL INCR(ARR(2),5) 12 | PRINT ARR(2) 13 | 14 | 15 | SUB HELLO 16 | PRINT "HELLO" 17 | END SUB 18 | 19 | SUB GREET(NAME$,COUNT) 20 | FOR I=1 TO COUNT 21 | PRINT "HI",NAME$ 22 | NEXT I 23 | END SUB 24 | 25 | SUB INCR(X,Y) 26 | X=X+Y 27 | END SUB 28 | -------------------------------------------------------------------------------- /programs test/Subs 2.nx: -------------------------------------------------------------------------------- 1 | DIM GLOBAL ARR(7) 2 | 3 | CALL RANDOM(ARR()) 4 | CALL PRINTARR 5 | 6 | 7 | SUB RANDOM(X()) 8 | FOR I=0 TO 7 9 | X(I)=INT(RND*100) 10 | NEXT I 11 | END SUB 12 | 13 | SUB PRINTARR 14 | FOR I=0 TO 7 15 | PRINT ARR(I) 16 | NEXT I 17 | END SUB 18 | -------------------------------------------------------------------------------- /programs test/drawing.nx: -------------------------------------------------------------------------------- 1 | REM ** FILL DRAWING AREA WITH CHARACTERS 2 | I=8 3 | ATTR (0,0,0,0,0) 4 | FOR CY=0 TO 8 5 | FOR CX=0 TO 19 6 | CELL CX,CY+3,I 7 | I=I+1 8 | NEXT CX 9 | NEXT CY 10 | 11 | REM ** SOME TEXT 12 | TEXT 0,0, " DRAWING WITH TILES?" 13 | TEXT 0,15," NO PROBLEM!" 14 | 15 | REM ** ANIMATE! 16 | GLOBAL RY,I 17 | I=0 18 | ON RASTER CALL RASTFX 19 | DO 20 | FILL $8080,2880,0 21 | 22 | CALL DRAWSINE(40+SIN(I*0.02)*20,0) 23 | CALL DRAWSINE(30+SIN(I*0.03)*10,1) 24 | 25 | I=I+1 26 | RY=INT(48-SIN(I*0.04)*48) 27 | WAIT VBL 28 | LOOP 29 | 30 | SUB RASTFX 31 | REM ** SCROLL TOP AND BOTTOM TEXT LINE 32 | IF RASTER<8 OR RASTER>=120 THEN SCROLL 0,I,0 ELSE SCROLL 0,0,0 33 | REM ** PALETTE FX 34 | IF RASTER=0 OR RASTER=RY+33 THEN PALETTE 0,%000001,%110000,%001100,%110100 35 | IF RASTER=RY THEN PALETTE 0,%000010,%001111,%110011,%111100 36 | END SUB 37 | 38 | SUB DRAWSINE(DIV,BP) 39 | FOR X=0 TO 159 40 | Y=36+SIN(X*PI/DIV)*35 41 | REM ** GET CHARACTER 42 | CX=INT(X/8) 43 | CY=INT(Y/8) 44 | CI=CY*20+CX 45 | REM ** GET BIT 46 | BI=2^(7-(X MOD 8)) 47 | REM ** WRITE IN CHARACTER RAM 48 | A=$8080+CI*16+(Y MOD 8)+BP*8 49 | POKE A,PEEK(A) OR BI 50 | NEXT X 51 | END SUB 52 | -------------------------------------------------------------------------------- /programs test/hello world.nx: -------------------------------------------------------------------------------- 1 | PRINT "HELLO WORLD" 2 | 3 | GAMEPAD 1 4 | 5 | BG 1 6 | BG COPY 0,0,32,32 TO 0,0 7 | 8 | X=32 9 | Y=32 10 | DO 11 | BGX=BGX+1 12 | SCROLL 1,BGX,0 13 | IF UP(0) THEN Y=Y-1 14 | IF DOWN(0) THEN Y=Y+1 15 | IF LEFT(0) THEN X=X-1 16 | IF RIGHT(0) THEN X=X+1 17 | SPRITE 0,X,Y,TIMER/8 MOD 2 + 1 18 | WAIT VBL 19 | LOOP 20 | 21 | #1:MAIN PALETTES 22 | 05 3F 2F 00 00 38 34 00 00 0C 24 10 00 3F 2A 15 23 | 00 00 00 00 00 00 00 00 00 00 00 00 00 3F 2A 15 24 | 25 | #2:MAIN CHARACTERS 26 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 27 | 18 18 81 00 00 18 18 3C 18 00 7E 18 18 18 18 3C 28 | 18 18 00 00 00 99 18 3C 18 00 18 3C 5A 18 18 3C 29 | FF FF 5E 04 00 44 FF FF 00 00 A1 FB FF FF FF FF 30 | 3C 3C 3C 3C 3C 3C 3C 3C 3C 3C 3C 3C 3C 3C 3C 3C 31 | 3C 7E FF FF FF FF FE 7C 00 00 00 00 00 00 00 00 32 | 10 08 08 88 49 2E 1C 1C 00 00 00 00 00 00 00 00 33 | 34 | #3:MAIN BG 35 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 36 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 37 | 00 00 00 00 05 02 00 00 00 00 05 02 00 00 00 00 38 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 39 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 05 02 40 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 41 | 00 00 03 02 03 02 03 02 03 02 03 02 03 02 00 00 42 | 00 00 00 00 00 00 00 00 05 22 00 00 00 00 00 00 43 | 00 00 00 00 00 00 00 00 00 00 00 00 03 02 03 02 44 | 03 02 00 00 00 00 00 00 00 00 00 00 00 00 00 00 45 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 46 | 00 00 00 00 00 00 03 22 03 22 03 22 00 00 00 00 47 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 48 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 49 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 05 22 50 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 51 | 00 00 05 02 00 00 00 00 00 00 00 00 00 00 00 00 52 | 00 00 00 00 00 00 00 00 05 02 00 00 06 12 00 00 53 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 05 22 54 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 55 | 00 00 05 02 00 00 00 00 00 00 00 00 00 00 00 00 56 | 00 00 00 00 00 00 03 02 03 02 03 02 03 02 03 02 57 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 04 22 58 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 59 | 00 00 04 02 06 02 00 00 00 00 00 00 00 00 00 00 60 | 05 23 00 00 00 00 00 00 00 00 00 00 00 00 00 00 61 | 00 00 00 00 00 00 00 00 00 00 03 22 03 22 03 22 62 | 03 22 00 00 00 00 00 00 00 00 00 00 05 22 00 00 63 | 03 02 03 02 03 02 03 02 00 00 00 00 00 00 00 00 64 | 05 23 00 00 00 00 00 00 00 00 00 00 00 00 00 00 65 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 66 | 00 00 00 00 00 00 00 00 00 00 00 00 05 22 00 00 67 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 68 | 05 23 00 00 00 00 00 00 00 00 00 00 00 00 00 00 69 | 00 00 05 02 00 00 00 00 00 00 00 00 00 00 00 00 70 | 00 00 00 00 00 00 00 00 00 00 00 00 05 22 00 00 71 | 00 00 00 00 00 00 00 00 00 00 00 00 06 2A 00 00 72 | 04 23 00 00 06 2A 00 00 00 00 00 00 00 00 06 12 73 | 00 00 04 02 00 00 06 1A 00 00 00 00 00 00 00 00 74 | 00 00 00 00 00 00 00 00 00 00 00 00 04 22 00 00 75 | 00 00 00 00 00 00 00 00 00 00 03 22 03 22 03 22 76 | 03 22 03 22 03 22 03 22 00 00 00 00 00 00 03 02 77 | 03 02 03 02 03 02 03 02 00 00 00 00 00 00 00 00 78 | 00 00 00 00 00 00 00 00 00 00 03 22 03 22 03 22 79 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 80 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 81 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 03 03 82 | 03 03 03 03 03 03 00 00 00 00 00 00 00 00 00 00 83 | 00 00 03 03 03 03 03 03 00 00 00 00 00 00 00 00 84 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 85 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 86 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 87 | 88 | -------------------------------------------------------------------------------- /programs test/sprite collision.nx: -------------------------------------------------------------------------------- 1 | PALETTE 1,0,4,8,16 2 | 3 | REM INIT SPRITES 4 | SPRITE.A 0,(0,1,0,,3) 5 | SPRITE.A 1,(1,0,1,,3) 6 | SPRITE.A 2,(1,0,0,,0) 7 | SPRITE.A 3,(1,0,0,,0) 8 | 9 | DIM X(1),Y(1) 10 | X=42 11 | Y=32 12 | SPRITE 0,X,Y,3 13 | SPRITE 1,88,48,3 14 | SPRITE 2,18,38,1 15 | SPRITE 3,128,98,2 16 | 17 | GAMEPAD 1 18 | 19 | DO 20 | IF UP(0) THEN Y=Y-1 21 | IF DOWN(0) THEN Y=Y+1 22 | IF LEFT(0) THEN X=X-1 23 | IF RIGHT(0) THEN X=X+1 24 | SPRITE 0,X,Y, 25 | IF SPRITE HIT(0) THEN TEXT 0,0,"HIT "+STR$(HIT) ELSE TEXT 0,0," " 26 | WAIT VBL 27 | LOOP 28 | 29 | 30 | #2:MAIN CHARACTERS 31 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 32 | 08 1C 3E FF 00 60 60 60 08 1C 3E 00 FF 60 60 60 33 | D8 08 00 08 08 09 00 01 E0 00 08 08 08 0E 01 01 34 | 80 60 38 1F 0B 09 08 08 00 00 00 00 04 06 07 06 35 | 00 00 00 81 C3 77 7C 00 00 00 00 00 00 80 83 FF 36 | 00 00 F0 00 00 00 00 00 00 00 00 FF FF 81 01 00 37 | 00 00 00 00 00 00 00 00 00 00 00 00 C0 E0 F8 7C 38 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 39 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 40 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 41 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 42 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 43 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 44 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 45 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 46 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 47 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 48 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 49 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 50 | 10 10 18 0E 02 03 01 01 0C 0C 06 01 01 00 00 00 51 | 00 00 00 00 00 00 00 00 00 00 00 00 00 80 80 C0 52 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 53 | 00 00 00 00 00 00 01 02 1E 0F 07 03 03 03 03 02 54 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 55 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 56 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 57 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 58 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 59 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 60 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 61 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 62 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 63 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 64 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 65 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 66 | 01 03 06 38 20 20 60 40 00 00 01 07 1C 10 10 20 67 | 00 00 00 00 00 00 00 00 C0 80 00 00 00 00 00 00 68 | 00 00 00 00 00 03 07 06 00 00 00 00 00 03 07 06 69 | 06 0E 1C 3C F8 F8 F0 00 06 0E 1C 3C F8 F8 F0 00 70 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 71 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 72 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 73 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 74 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 75 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 76 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 77 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 78 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 79 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 80 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 81 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 82 | 00 00 00 00 00 00 00 00 60 60 30 38 1F 07 00 00 83 | 00 00 00 00 00 00 00 00 00 00 00 C0 E0 F0 1C 0F 84 | 06 0E 1C 1C 1C 38 F0 E0 06 0E 1C 1C 1C 38 F0 E0 85 | -------------------------------------------------------------------------------- /programs/Gfx Designer 2.0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timoinutilis/lowres-nx/85c80181d26bb5c2147ebc76bfc48bce9f8d73a8/programs/Gfx Designer 2.0.png -------------------------------------------------------------------------------- /programs/LowRes Adventure 1.1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timoinutilis/lowres-nx/85c80181d26bb5c2147ebc76bfc48bce9f8d73a8/programs/LowRes Adventure 1.1.png -------------------------------------------------------------------------------- /programs/LowRes Galaxy 2 (1.5).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timoinutilis/lowres-nx/85c80181d26bb5c2147ebc76bfc48bce9f8d73a8/programs/LowRes Galaxy 2 (1.5).png -------------------------------------------------------------------------------- /programs/Sound Composer 1.5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timoinutilis/lowres-nx/85c80181d26bb5c2147ebc76bfc48bce9f8d73a8/programs/Sound Composer 1.5.png -------------------------------------------------------------------------------- /programs/Star Scroller 1.2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timoinutilis/lowres-nx/85c80181d26bb5c2147ebc76bfc48bce9f8d73a8/programs/Star Scroller 1.2.png -------------------------------------------------------------------------------- /scripts/export_characters.py: -------------------------------------------------------------------------------- 1 | import sys 2 | from PIL import Image 3 | 4 | if len(sys.argv) >= 2: 5 | filename = sys.argv[1] 6 | else: 7 | filename = "../assets/characters.png" 8 | im = Image.open(filename) 9 | print im.format, im.size, im.mode 10 | print "{", 11 | for row in range(16): 12 | for column in range(16): 13 | print "{", 14 | for bit in range(2): 15 | for charY in range(8): 16 | y = row*8+charY 17 | val = 0 18 | for charX in range(8): 19 | pixel = im.getpixel((column*8+charX, y))[0] / 64 20 | pcolor = 0 21 | if pixel > 0: 22 | pcolor = 4 - pixel 23 | pbit = (pcolor >> bit) & 0x01 24 | val |= (pbit << (7-charX)) 25 | print str(val & 0xFF)+ ",", 26 | print "}," 27 | print "}" -------------------------------------------------------------------------------- /scripts/export_characters_hex.py: -------------------------------------------------------------------------------- 1 | import sys 2 | from PIL import Image 3 | 4 | if len(sys.argv) >= 2: 5 | filename = sys.argv[1] 6 | else: 7 | filename = "../assets/characters.png" 8 | im = Image.open(filename) 9 | print im.format, im.size, im.mode 10 | for row in range(16): 11 | for column in range(16): 12 | for bit in range(2): 13 | for charY in range(8): 14 | y = row*8+charY 15 | val = 0 16 | for charX in range(8): 17 | pixel = im.getpixel((column*8+charX, y))[0] / 64 18 | pcolor = 0 19 | if pixel > 0: 20 | pcolor = 4 - pixel 21 | pbit = (pcolor >> bit) & 0x01 22 | val |= (pbit << (7-charX)) 23 | print "%0.2X" % (val & 0xFF), 24 | print "" 25 | -------------------------------------------------------------------------------- /sdl/config.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright 2018 Timo Kloss 3 | // 4 | // This software is provided 'as-is', without any express or implied 5 | // warranty. In no event will the authors be held liable for any damages 6 | // arising from the use of this software. 7 | // 8 | // Permission is granted to anyone to use this software for any purpose, 9 | // including commercial applications, and to alter it and redistribute it 10 | // freely, subject to the following restrictions: 11 | // 12 | // 1. The origin of this software must not be misrepresented; you must not 13 | // claim that you wrote the original software. If you use this software 14 | // in a product, an acknowledgment in the product documentation would be 15 | // appreciated but is not required. 16 | // 2. Altered source versions must be plainly marked as such, and must not be 17 | // misrepresented as being the original software. 18 | // 3. This notice may not be removed or altered from any source distribution. 19 | // 20 | 21 | #ifndef config_h 22 | #define config_h 23 | 24 | #ifdef __EMSCRIPTEN__ 25 | #define DEV_MENU 0 26 | #define SCREENSHOTS 0 27 | #define HOT_KEYS 0 28 | #define SETTINGS_FILE 0 29 | #else 30 | #define DEV_MENU 1 31 | #define SCREENSHOTS 1 32 | #define HOT_KEYS 1 33 | #define SETTINGS_FILE 1 34 | #endif 35 | 36 | #endif /* config_h */ 37 | -------------------------------------------------------------------------------- /sdl/dev_menu.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright 2017 Timo Kloss 3 | // 4 | // This software is provided 'as-is', without any express or implied 5 | // warranty. In no event will the authors be held liable for any damages 6 | // arising from the use of this software. 7 | // 8 | // Permission is granted to anyone to use this software for any purpose, 9 | // including commercial applications, and to alter it and redistribute it 10 | // freely, subject to the following restrictions: 11 | // 12 | // 1. The origin of this software must not be misrepresented; you must not 13 | // claim that you wrote the original software. If you use this software 14 | // in a product, an acknowledgment in the product documentation would be 15 | // appreciated but is not required. 16 | // 2. Altered source versions must be plainly marked as such, and must not be 17 | // misrepresented as being the original software. 18 | // 3. This notice may not be removed or altered from any source distribution. 19 | // 20 | 21 | #ifndef dev_menu_h 22 | #define dev_menu_h 23 | 24 | #include "config.h" 25 | 26 | #if DEV_MENU 27 | 28 | #include 29 | #include 30 | #include "core.h" 31 | #include "settings.h" 32 | #include "runner.h" 33 | #include "text_lib.h" 34 | 35 | enum DevModeMenu { 36 | DevModeMenuMain, 37 | DevModeMenuTools, 38 | DevModeMenuClearRam 39 | }; 40 | 41 | struct DevMenu { 42 | struct Runner *runner; 43 | struct Settings *settings; 44 | bool lastTouch; 45 | enum DevModeMenu currentMenu; 46 | int currentButton; 47 | int currentMenuSize; 48 | struct CoreError lastError; 49 | struct TextLib textLib; 50 | }; 51 | 52 | void dev_init(struct DevMenu *devMenu, struct Runner *runner, struct Settings *settings); 53 | void dev_show(struct DevMenu *devMenu, bool reload); 54 | void dev_update(struct DevMenu *devMenu, struct CoreInput *input); 55 | bool dev_handleDropFile(struct DevMenu *devMenu, const char *filename); 56 | 57 | #endif 58 | 59 | #endif /* dev_menu_h */ 60 | -------------------------------------------------------------------------------- /sdl/main.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright 2017-2020 Timo Kloss 3 | // 4 | // This software is provided 'as-is', without any express or implied 5 | // warranty. In no event will the authors be held liable for any damages 6 | // arising from the use of this software. 7 | // 8 | // Permission is granted to anyone to use this software for any purpose, 9 | // including commercial applications, and to alter it and redistribute it 10 | // freely, subject to the following restrictions: 11 | // 12 | // 1. The origin of this software must not be misrepresented; you must not 13 | // claim that you wrote the original software. If you use this software 14 | // in a product, an acknowledgment in the product documentation would be 15 | // appreciated but is not required. 16 | // 2. Altered source versions must be plainly marked as such, and must not be 17 | // misrepresented as being the original software. 18 | // 3. This notice may not be removed or altered from any source distribution. 19 | // 20 | 21 | #ifndef main_h 22 | #define main_h 23 | 24 | #include 25 | 26 | enum MainState { 27 | MainStateUndefined, 28 | MainStateBootIntro, 29 | MainStateRunningProgram, 30 | MainStateRunningTool, 31 | MainStateDevMenu, 32 | }; 33 | 34 | enum Zoom { 35 | ZoomPixelPerfect, 36 | ZoomLarge, 37 | ZoomOverscan, 38 | ZoomSqueeze, 39 | }; 40 | 41 | void bootNX(void); 42 | void rebootNX(void); 43 | bool hasProgram(void); 44 | const char *getMainProgramFilename(void); 45 | void selectProgram(const char *filename); 46 | void runMainProgram(void); 47 | void runToolProgram(const char *filename); 48 | void showDevMenu(void); 49 | bool usesMainProgramAsDisk(void); 50 | void getDiskFilename(char *outputString); 51 | void getRamFilename(char *outputString); 52 | void setMouseEnabled(bool enabled); 53 | 54 | #endif /* main_h */ 55 | -------------------------------------------------------------------------------- /sdl/runner.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright 2017-2018 Timo Kloss 3 | // 4 | // This software is provided 'as-is', without any express or implied 5 | // warranty. In no event will the authors be held liable for any damages 6 | // arising from the use of this software. 7 | // 8 | // Permission is granted to anyone to use this software for any purpose, 9 | // including commercial applications, and to alter it and redistribute it 10 | // freely, subject to the following restrictions: 11 | // 12 | // 1. The origin of this software must not be misrepresented; you must not 13 | // claim that you wrote the original software. If you use this software 14 | // in a product, an acknowledgment in the product documentation would be 15 | // appreciated but is not required. 16 | // 2. Altered source versions must be plainly marked as such, and must not be 17 | // misrepresented as being the original software. 18 | // 3. This notice may not be removed or altered from any source distribution. 19 | // 20 | 21 | #ifndef runner_h 22 | #define runner_h 23 | 24 | #include 25 | #include 26 | #include "core.h" 27 | 28 | struct Runner { 29 | struct Core *core; 30 | struct CoreDelegate coreDelegate; 31 | bool messageShownUsingDisk; 32 | }; 33 | 34 | void runner_init(struct Runner *runner); 35 | void runner_deinit(struct Runner *runner); 36 | bool runner_isOkay(struct Runner *runner); 37 | struct CoreError runner_loadProgram(struct Runner *runner, const char *filename); 38 | 39 | #endif /* runner_h */ 40 | -------------------------------------------------------------------------------- /sdl/screenshot.c: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright 2018 Timo Kloss 3 | // 4 | // This software is provided 'as-is', without any express or implied 5 | // warranty. In no event will the authors be held liable for any damages 6 | // arising from the use of this software. 7 | // 8 | // Permission is granted to anyone to use this software for any purpose, 9 | // including commercial applications, and to alter it and redistribute it 10 | // freely, subject to the following restrictions: 11 | // 12 | // 1. The origin of this software must not be misrepresented; you must not 13 | // claim that you wrote the original software. If you use this software 14 | // in a product, an acknowledgment in the product documentation would be 15 | // appreciated but is not required. 16 | // 2. Altered source versions must be plainly marked as such, and must not be 17 | // misrepresented as being the original software. 18 | // 3. This notice may not be removed or altered from any source distribution. 19 | // 20 | 21 | #include "config.h" 22 | 23 | #if SCREENSHOTS 24 | 25 | #include "screenshot.h" 26 | #include "system_paths.h" 27 | #include "core.h" 28 | #include 29 | #include 30 | #include 31 | 32 | #define STB_IMAGE_WRITE_IMPLEMENTATION 33 | #include "stb_image_write.h" 34 | 35 | bool writeImage(const char *filename, int width, int height, uint32_t *pixels, int scale) 36 | { 37 | uint8_t *data = malloc(width * height * 3 * scale * scale); 38 | if (data) 39 | { 40 | int i = 0; 41 | for (int y = 0; y < height; y++) 42 | { 43 | for (int ys = 0; ys < scale; ys++) 44 | { 45 | for (int x = 0; x < width; x++) 46 | { 47 | uint32_t pixel = pixels[y * width + x]; 48 | for (int xs = 0; xs < scale; xs++) 49 | { 50 | data[i++] = (pixel) & 0xFF; 51 | data[i++] = (pixel >> 8) & 0xFF; 52 | data[i++] = (pixel >> 16) & 0xFF; 53 | } 54 | } 55 | } 56 | } 57 | 58 | int result = stbi_write_png(filename, width * scale, height * scale, 3, data, width * 3 * scale); 59 | free(data); 60 | 61 | return (result != 0); 62 | } 63 | return false; 64 | } 65 | 66 | bool screenshot_save(uint32_t *pixels, int scale) 67 | { 68 | char filename[FILENAME_MAX]; 69 | 70 | desktop_path(filename, FILENAME_MAX); 71 | size_t len = strlen(filename); 72 | 73 | time_t rawtime; 74 | time(&rawtime); 75 | struct tm *timeinfo = localtime(&rawtime); 76 | strftime(&filename[len], FILENAME_MAX - len - 1, "LowRes NX %Y-%m-%d %H_%M_%S.png", timeinfo); 77 | 78 | return writeImage(filename, SCREEN_WIDTH, SCREEN_HEIGHT, pixels, scale); 79 | } 80 | 81 | #endif 82 | -------------------------------------------------------------------------------- /sdl/screenshot.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright 2018 Timo Kloss 3 | // 4 | // This software is provided 'as-is', without any express or implied 5 | // warranty. In no event will the authors be held liable for any damages 6 | // arising from the use of this software. 7 | // 8 | // Permission is granted to anyone to use this software for any purpose, 9 | // including commercial applications, and to alter it and redistribute it 10 | // freely, subject to the following restrictions: 11 | // 12 | // 1. The origin of this software must not be misrepresented; you must not 13 | // claim that you wrote the original software. If you use this software 14 | // in a product, an acknowledgment in the product documentation would be 15 | // appreciated but is not required. 16 | // 2. Altered source versions must be plainly marked as such, and must not be 17 | // misrepresented as being the original software. 18 | // 3. This notice may not be removed or altered from any source distribution. 19 | // 20 | 21 | #ifndef screenshot_h 22 | #define screenshot_h 23 | 24 | #include "config.h" 25 | 26 | #if SCREENSHOTS 27 | 28 | #include 29 | #include 30 | #include 31 | 32 | bool screenshot_save(uint32_t *pixels, int scale); 33 | 34 | #endif 35 | 36 | #endif /* screenshot_h */ 37 | -------------------------------------------------------------------------------- /sdl/sdl_include.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright 2018 Timo Kloss 3 | // 4 | // This software is provided 'as-is', without any express or implied 5 | // warranty. In no event will the authors be held liable for any damages 6 | // arising from the use of this software. 7 | // 8 | // Permission is granted to anyone to use this software for any purpose, 9 | // including commercial applications, and to alter it and redistribute it 10 | // freely, subject to the following restrictions: 11 | // 12 | // 1. The origin of this software must not be misrepresented; you must not 13 | // claim that you wrote the original software. If you use this software 14 | // in a product, an acknowledgment in the product documentation would be 15 | // appreciated but is not required. 16 | // 2. Altered source versions must be plainly marked as such, and must not be 17 | // misrepresented as being the original software. 18 | // 3. This notice may not be removed or altered from any source distribution. 19 | // 20 | 21 | #if defined(_WIN32) 22 | #include 23 | #else 24 | #include 25 | #endif 26 | -------------------------------------------------------------------------------- /sdl/settings.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright 2017-2020 Timo Kloss 3 | // 4 | // This software is provided 'as-is', without any express or implied 5 | // warranty. In no event will the authors be held liable for any damages 6 | // arising from the use of this software. 7 | // 8 | // Permission is granted to anyone to use this software for any purpose, 9 | // including commercial applications, and to alter it and redistribute it 10 | // freely, subject to the following restrictions: 11 | // 12 | // 1. The origin of this software must not be misrepresented; you must not 13 | // claim that you wrote the original software. If you use this software 14 | // in a product, an acknowledgment in the product documentation would be 15 | // appreciated but is not required. 16 | // 2. Altered source versions must be plainly marked as such, and must not be 17 | // misrepresented as being the original software. 18 | // 3. This notice may not be removed or altered from any source distribution. 19 | // 20 | 21 | #ifndef settings_h 22 | #define settings_h 23 | 24 | #include 25 | #include 26 | 27 | #define MAX_TOOLS 4 28 | #define TOOL_NAME_SIZE 21 29 | 30 | struct Parameters { 31 | bool fullscreen; 32 | int zoom; 33 | bool disabledev; 34 | int mapping; 35 | int disabledelay; 36 | }; 37 | 38 | struct Settings { 39 | struct Parameters file; 40 | struct Parameters session; 41 | int numTools; 42 | char tools[MAX_TOOLS][FILENAME_MAX]; 43 | char toolNames[MAX_TOOLS][TOOL_NAME_SIZE]; 44 | }; 45 | 46 | void settings_init(struct Settings *settings, char *filenameOut, int argc, const char * argv[]); 47 | void settings_save(struct Settings *settings); 48 | bool settings_addTool(struct Settings *settings, const char *filename); 49 | void settings_removeTool(struct Settings *settings, int index); 50 | 51 | #endif /* settings_h */ 52 | -------------------------------------------------------------------------------- /sdl/system_paths.c: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright 2018 Timo Kloss 3 | // 4 | // This software is provided 'as-is', without any express or implied 5 | // warranty. In no event will the authors be held liable for any damages 6 | // arising from the use of this software. 7 | // 8 | // Permission is granted to anyone to use this software for any purpose, 9 | // including commercial applications, and to alter it and redistribute it 10 | // freely, subject to the following restrictions: 11 | // 12 | // 1. The origin of this software must not be misrepresented; you must not 13 | // claim that you wrote the original software. If you use this software 14 | // in a product, an acknowledgment in the product documentation would be 15 | // appreciated but is not required. 16 | // 2. Altered source versions must be plainly marked as such, and must not be 17 | // misrepresented as being the original software. 18 | // 3. This notice may not be removed or altered from any source distribution. 19 | // 20 | 21 | #include "system_paths.h" 22 | #include 23 | #include 24 | 25 | #if defined(_WIN32) 26 | #include 27 | #endif 28 | 29 | void desktop_path(char *buffer, size_t size) 30 | { 31 | #if defined(__APPLE__) && defined(__MACH__) 32 | strncpy(buffer, getenv("HOME"), size - 1); 33 | strncat(buffer, "/Desktop/", size - 1); 34 | #elif defined(_WIN32) 35 | strncpy(buffer, getenv("USERPROFILE"), size - 1); 36 | strncat(buffer, "\\Desktop\\", size - 1); 37 | #elif defined(__EMSCRIPTEN__) 38 | strncpy(buffer, "", size - 1); 39 | #elif defined(__LINUX__) 40 | strncpy(buffer, getenv("HOME"), size - 1); 41 | strncat(buffer, "/Desktop/", size - 1); 42 | #else 43 | #error Not implemented yet 44 | #endif 45 | } 46 | 47 | FILE* fopen_utf8(const char* filename, const char* mode) 48 | { 49 | #if defined(_WIN32) 50 | WCHAR nameW[FILENAME_MAX] = { 0 }; 51 | WCHAR modeW[16] = { 0 }; 52 | int len = MultiByteToWideChar(CP_UTF8, 0, filename, -1, nameW, FILENAME_MAX); 53 | if (len > 0 && MultiByteToWideChar(CP_UTF8, 0, mode, -1, modeW, 16) > 0) 54 | { 55 | FILE* ret = NULL; 56 | if (_wfopen_s(&ret, nameW, modeW) == 0) 57 | return ret; 58 | } 59 | return NULL; 60 | #else 61 | return fopen(filename, mode); 62 | #endif 63 | } 64 | -------------------------------------------------------------------------------- /sdl/system_paths.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright 2018 Timo Kloss 3 | // 4 | // This software is provided 'as-is', without any express or implied 5 | // warranty. In no event will the authors be held liable for any damages 6 | // arising from the use of this software. 7 | // 8 | // Permission is granted to anyone to use this software for any purpose, 9 | // including commercial applications, and to alter it and redistribute it 10 | // freely, subject to the following restrictions: 11 | // 12 | // 1. The origin of this software must not be misrepresented; you must not 13 | // claim that you wrote the original software. If you use this software 14 | // in a product, an acknowledgment in the product documentation would be 15 | // appreciated but is not required. 16 | // 2. Altered source versions must be plainly marked as such, and must not be 17 | // misrepresented as being the original software. 18 | // 3. This notice may not be removed or altered from any source distribution. 19 | // 20 | 21 | #ifndef system_paths_h 22 | #define system_paths_h 23 | 24 | #include 25 | 26 | #ifdef _WIN32 27 | #define PATH_SEPARATOR "\\" 28 | #define PATH_SEPARATOR_CHAR '\\' 29 | #else 30 | #define PATH_SEPARATOR "/" 31 | #define PATH_SEPARATOR_CHAR '/' 32 | #endif 33 | 34 | void desktop_path(char *buffer, size_t size); 35 | FILE* fopen_utf8(const char* filename, const char* mode); 36 | 37 | #endif /* system_paths_h */ 38 | -------------------------------------------------------------------------------- /sdl/utils.c: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright 2018 Timo Kloss 3 | // 4 | // This software is provided 'as-is', without any express or implied 5 | // warranty. In no event will the authors be held liable for any damages 6 | // arising from the use of this software. 7 | // 8 | // Permission is granted to anyone to use this software for any purpose, 9 | // including commercial applications, and to alter it and redistribute it 10 | // freely, subject to the following restrictions: 11 | // 12 | // 1. The origin of this software must not be misrepresented; you must not 13 | // claim that you wrote the original software. If you use this software 14 | // in a product, an acknowledgment in the product documentation would be 15 | // appreciated but is not required. 16 | // 2. Altered source versions must be plainly marked as such, and must not be 17 | // misrepresented as being the original software. 18 | // 3. This notice may not be removed or altered from any source distribution. 19 | // 20 | 21 | #include "utils.h" 22 | #include "system_paths.h" 23 | #include 24 | 25 | void displayName(const char *filename, char *destination, size_t size) 26 | { 27 | memset(destination, 0, size); 28 | 29 | const char *nameStart = filename; 30 | char *slash = strrchr(filename, PATH_SEPARATOR_CHAR); 31 | if (slash) 32 | { 33 | nameStart = slash + 1; 34 | } 35 | strncpy(destination, nameStart, size - 1); 36 | 37 | char *dot = strrchr(nameStart, '.'); 38 | if (dot) 39 | { 40 | int dotIndex = (int)(dot - nameStart); 41 | if (dotIndex < size) 42 | { 43 | destination[dotIndex] = 0; 44 | } 45 | } 46 | } 47 | 48 | bool hasPostfix(const char *string, const char *postfix) 49 | { 50 | size_t stringLen = strlen(string); 51 | size_t postfixLen = strlen(postfix); 52 | if (postfixLen <= stringLen) 53 | { 54 | string = string + stringLen - postfixLen; 55 | return strcmp(string, postfix) == 0; 56 | } 57 | return false; 58 | } 59 | -------------------------------------------------------------------------------- /sdl/utils.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright 2018 Timo Kloss 3 | // 4 | // This software is provided 'as-is', without any express or implied 5 | // warranty. In no event will the authors be held liable for any damages 6 | // arising from the use of this software. 7 | // 8 | // Permission is granted to anyone to use this software for any purpose, 9 | // including commercial applications, and to alter it and redistribute it 10 | // freely, subject to the following restrictions: 11 | // 12 | // 1. The origin of this software must not be misrepresented; you must not 13 | // claim that you wrote the original software. If you use this software 14 | // in a product, an acknowledgment in the product documentation would be 15 | // appreciated but is not required. 16 | // 2. Altered source versions must be plainly marked as such, and must not be 17 | // misrepresented as being the original software. 18 | // 3. This notice may not be removed or altered from any source distribution. 19 | // 20 | 21 | #ifndef utils_h 22 | #define utils_h 23 | 24 | #include 25 | #include 26 | 27 | void displayName(const char *filename, char *destination, size_t size); 28 | bool hasPostfix(const char *string, const char *postfix); 29 | 30 | #endif /* utils_h */ 31 | --------------------------------------------------------------------------------