├── .github └── workflows │ └── assemble_and_publish_release.yml ├── .gitignore ├── LICENSE ├── README.md ├── appy.yaml ├── content ├── KFEST2013B.PAK ├── song3.nt └── torus00.bin ├── documentation ├── CrashCourse.pdf ├── GS Video Layout.pdf └── GS Video Registers.pdf └── source ├── demo.s ├── font.s ├── gslib.mac.s ├── p8_tools.s ├── quit.s ├── quit16.s ├── quit8.s ├── shr1.s ├── shr2.s ├── shrhello.s ├── shrloadimg.m.s ├── shrloadimg.s ├── skel.macgen.s └── torus.s /.github/workflows/assemble_and_publish_release.yml: -------------------------------------------------------------------------------- 1 | name: GSLib CI (Appy Project - 65xxx Assemble+Package) 2 | 3 | on: 4 | pull_request: 5 | push: 6 | 7 | jobs: 8 | appy-ci: 9 | runs-on: ubuntu-latest 10 | steps: 11 | - name: Checkout 12 | uses: actions/checkout@v3 13 | with: 14 | fetch-depth: 0 15 | # This will install Appy plus Merlin32 and Cadius on your Github Runner machine 16 | - name: Install Appy 17 | uses: digarok/install-appy-pack-action@main 18 | with: 19 | include_prodos: true 20 | # appy_version: v0.1.7 21 | # Now you can use it to assemble your project(s) 22 | - name: Assemble 23 | run: | 24 | appy asm 25 | # This could be one step but I like to see the disk image separately in github UI 26 | - name: Create Disk Image 27 | run: | 28 | appy disk 29 | - name: Create Release 30 | id: create_release 31 | if: startsWith(github.ref, 'refs/tags/v') 32 | uses: actions/create-release@v1 33 | env: 34 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 35 | with: 36 | tag_name: ${{ github.ref }} 37 | release_name: Release ${{ github.ref }} 38 | - name: Upload Release Asset - 800KB ProDOS Image 39 | if: startsWith(github.ref, 'refs/tags/v') 40 | uses: actions/upload-release-asset@v1.0.1 41 | env: 42 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 43 | with: 44 | upload_url: ${{ steps.create_release.outputs.upload_url }} 45 | asset_path: ./demodisk800.2mg 46 | asset_name: demodisk800.2mg 47 | asset_content_type: application/octet-stream 48 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *_Output.txt 2 | *.Sys16 3 | *.S16 4 | *.system 5 | *.2mg 6 | _FileInformation.txt -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 2, June 1991 3 | 4 | Copyright (C) 1989, 1991 Free Software Foundation, Inc., 5 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 6 | Everyone is permitted to copy and distribute verbatim copies 7 | of this license document, but changing it is not allowed. 8 | 9 | Preamble 10 | 11 | The licenses for most software are designed to take away your 12 | freedom to share and change it. By contrast, the GNU General Public 13 | License is intended to guarantee your freedom to share and change free 14 | software--to make sure the software is free for all its users. This 15 | General Public License applies to most of the Free Software 16 | Foundation's software and to any other program whose authors commit to 17 | using it. (Some other Free Software Foundation software is covered by 18 | the GNU Lesser General Public License instead.) You can apply it to 19 | your programs, too. 20 | 21 | When we speak of free software, we are referring to freedom, not 22 | price. Our General Public Licenses are designed to make sure that you 23 | have the freedom to distribute copies of free software (and charge for 24 | this service if you wish), that you receive source code or can get it 25 | if you want it, that you can change the software or use pieces of it 26 | in new free programs; and that you know you can do these things. 27 | 28 | To protect your rights, we need to make restrictions that forbid 29 | anyone to deny you these rights or to ask you to surrender the rights. 30 | These restrictions translate to certain responsibilities for you if you 31 | distribute copies of the software, or if you modify it. 32 | 33 | For example, if you distribute copies of such a program, whether 34 | gratis or for a fee, you must give the recipients all the rights that 35 | you have. You must make sure that they, too, receive or can get the 36 | source code. And you must show them these terms so they know their 37 | rights. 38 | 39 | We protect your rights with two steps: (1) copyright the software, and 40 | (2) offer you this license which gives you legal permission to copy, 41 | distribute and/or modify the software. 42 | 43 | Also, for each author's protection and ours, we want to make certain 44 | that everyone understands that there is no warranty for this free 45 | software. If the software is modified by someone else and passed on, we 46 | want its recipients to know that what they have is not the original, so 47 | that any problems introduced by others will not reflect on the original 48 | authors' reputations. 49 | 50 | Finally, any free program is threatened constantly by software 51 | patents. We wish to avoid the danger that redistributors of a free 52 | program will individually obtain patent licenses, in effect making the 53 | program proprietary. To prevent this, we have made it clear that any 54 | patent must be licensed for everyone's free use or not licensed at all. 55 | 56 | The precise terms and conditions for copying, distribution and 57 | modification follow. 58 | 59 | GNU GENERAL PUBLIC LICENSE 60 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 61 | 62 | 0. This License applies to any program or other work which contains 63 | a notice placed by the copyright holder saying it may be distributed 64 | under the terms of this General Public License. The "Program", below, 65 | refers to any such program or work, and a "work based on the Program" 66 | means either the Program or any derivative work under copyright law: 67 | that is to say, a work containing the Program or a portion of it, 68 | either verbatim or with modifications and/or translated into another 69 | language. (Hereinafter, translation is included without limitation in 70 | the term "modification".) Each licensee is addressed as "you". 71 | 72 | Activities other than copying, distribution and modification are not 73 | covered by this License; they are outside its scope. The act of 74 | running the Program is not restricted, and the output from the Program 75 | is covered only if its contents constitute a work based on the 76 | Program (independent of having been made by running the Program). 77 | Whether that is true depends on what the Program does. 78 | 79 | 1. You may copy and distribute verbatim copies of the Program's 80 | source code as you receive it, in any medium, provided that you 81 | conspicuously and appropriately publish on each copy an appropriate 82 | copyright notice and disclaimer of warranty; keep intact all the 83 | notices that refer to this License and to the absence of any warranty; 84 | and give any other recipients of the Program a copy of this License 85 | along with the Program. 86 | 87 | You may charge a fee for the physical act of transferring a copy, and 88 | you may at your option offer warranty protection in exchange for a fee. 89 | 90 | 2. You may modify your copy or copies of the Program or any portion 91 | of it, thus forming a work based on the Program, and copy and 92 | distribute such modifications or work under the terms of Section 1 93 | above, provided that you also meet all of these conditions: 94 | 95 | a) You must cause the modified files to carry prominent notices 96 | stating that you changed the files and the date of any change. 97 | 98 | b) You must cause any work that you distribute or publish, that in 99 | whole or in part contains or is derived from the Program or any 100 | part thereof, to be licensed as a whole at no charge to all third 101 | parties under the terms of this License. 102 | 103 | c) If the modified program normally reads commands interactively 104 | when run, you must cause it, when started running for such 105 | interactive use in the most ordinary way, to print or display an 106 | announcement including an appropriate copyright notice and a 107 | notice that there is no warranty (or else, saying that you provide 108 | a warranty) and that users may redistribute the program under 109 | these conditions, and telling the user how to view a copy of this 110 | License. (Exception: if the Program itself is interactive but 111 | does not normally print such an announcement, your work based on 112 | the Program is not required to print an announcement.) 113 | 114 | These requirements apply to the modified work as a whole. If 115 | identifiable sections of that work are not derived from the Program, 116 | and can be reasonably considered independent and separate works in 117 | themselves, then this License, and its terms, do not apply to those 118 | sections when you distribute them as separate works. But when you 119 | distribute the same sections as part of a whole which is a work based 120 | on the Program, the distribution of the whole must be on the terms of 121 | this License, whose permissions for other licensees extend to the 122 | entire whole, and thus to each and every part regardless of who wrote it. 123 | 124 | Thus, it is not the intent of this section to claim rights or contest 125 | your rights to work written entirely by you; rather, the intent is to 126 | exercise the right to control the distribution of derivative or 127 | collective works based on the Program. 128 | 129 | In addition, mere aggregation of another work not based on the Program 130 | with the Program (or with a work based on the Program) on a volume of 131 | a storage or distribution medium does not bring the other work under 132 | the scope of this License. 133 | 134 | 3. You may copy and distribute the Program (or a work based on it, 135 | under Section 2) in object code or executable form under the terms of 136 | Sections 1 and 2 above provided that you also do one of the following: 137 | 138 | a) Accompany it with the complete corresponding machine-readable 139 | source code, which must be distributed under the terms of Sections 140 | 1 and 2 above on a medium customarily used for software interchange; or, 141 | 142 | b) Accompany it with a written offer, valid for at least three 143 | years, to give any third party, for a charge no more than your 144 | cost of physically performing source distribution, a complete 145 | machine-readable copy of the corresponding source code, to be 146 | distributed under the terms of Sections 1 and 2 above on a medium 147 | customarily used for software interchange; or, 148 | 149 | c) Accompany it with the information you received as to the offer 150 | to distribute corresponding source code. (This alternative is 151 | allowed only for noncommercial distribution and only if you 152 | received the program in object code or executable form with such 153 | an offer, in accord with Subsection b above.) 154 | 155 | The source code for a work means the preferred form of the work for 156 | making modifications to it. For an executable work, complete source 157 | code means all the source code for all modules it contains, plus any 158 | associated interface definition files, plus the scripts used to 159 | control compilation and installation of the executable. However, as a 160 | special exception, the source code distributed need not include 161 | anything that is normally distributed (in either source or binary 162 | form) with the major components (compiler, kernel, and so on) of the 163 | operating system on which the executable runs, unless that component 164 | itself accompanies the executable. 165 | 166 | If distribution of executable or object code is made by offering 167 | access to copy from a designated place, then offering equivalent 168 | access to copy the source code from the same place counts as 169 | distribution of the source code, even though third parties are not 170 | compelled to copy the source along with the object code. 171 | 172 | 4. You may not copy, modify, sublicense, or distribute the Program 173 | except as expressly provided under this License. Any attempt 174 | otherwise to copy, modify, sublicense or distribute the Program is 175 | void, and will automatically terminate your rights under this License. 176 | However, parties who have received copies, or rights, from you under 177 | this License will not have their licenses terminated so long as such 178 | parties remain in full compliance. 179 | 180 | 5. You are not required to accept this License, since you have not 181 | signed it. However, nothing else grants you permission to modify or 182 | distribute the Program or its derivative works. These actions are 183 | prohibited by law if you do not accept this License. Therefore, by 184 | modifying or distributing the Program (or any work based on the 185 | Program), you indicate your acceptance of this License to do so, and 186 | all its terms and conditions for copying, distributing or modifying 187 | the Program or works based on it. 188 | 189 | 6. Each time you redistribute the Program (or any work based on the 190 | Program), the recipient automatically receives a license from the 191 | original licensor to copy, distribute or modify the Program subject to 192 | these terms and conditions. You may not impose any further 193 | restrictions on the recipients' exercise of the rights granted herein. 194 | You are not responsible for enforcing compliance by third parties to 195 | this License. 196 | 197 | 7. If, as a consequence of a court judgment or allegation of patent 198 | infringement or for any other reason (not limited to patent issues), 199 | conditions are imposed on you (whether by court order, agreement or 200 | otherwise) that contradict the conditions of this License, they do not 201 | excuse you from the conditions of this License. If you cannot 202 | distribute so as to satisfy simultaneously your obligations under this 203 | License and any other pertinent obligations, then as a consequence you 204 | may not distribute the Program at all. For example, if a patent 205 | license would not permit royalty-free redistribution of the Program by 206 | all those who receive copies directly or indirectly through you, then 207 | the only way you could satisfy both it and this License would be to 208 | refrain entirely from distribution of the Program. 209 | 210 | If any portion of this section is held invalid or unenforceable under 211 | any particular circumstance, the balance of the section is intended to 212 | apply and the section as a whole is intended to apply in other 213 | circumstances. 214 | 215 | It is not the purpose of this section to induce you to infringe any 216 | patents or other property right claims or to contest validity of any 217 | such claims; this section has the sole purpose of protecting the 218 | integrity of the free software distribution system, which is 219 | implemented by public license practices. Many people have made 220 | generous contributions to the wide range of software distributed 221 | through that system in reliance on consistent application of that 222 | system; it is up to the author/donor to decide if he or she is willing 223 | to distribute software through any other system and a licensee cannot 224 | impose that choice. 225 | 226 | This section is intended to make thoroughly clear what is believed to 227 | be a consequence of the rest of this License. 228 | 229 | 8. If the distribution and/or use of the Program is restricted in 230 | certain countries either by patents or by copyrighted interfaces, the 231 | original copyright holder who places the Program under this License 232 | may add an explicit geographical distribution limitation excluding 233 | those countries, so that distribution is permitted only in or among 234 | countries not thus excluded. In such case, this License incorporates 235 | the limitation as if written in the body of this License. 236 | 237 | 9. The Free Software Foundation may publish revised and/or new versions 238 | of the General Public License from time to time. Such new versions will 239 | be similar in spirit to the present version, but may differ in detail to 240 | address new problems or concerns. 241 | 242 | Each version is given a distinguishing version number. If the Program 243 | specifies a version number of this License which applies to it and "any 244 | later version", you have the option of following the terms and conditions 245 | either of that version or of any later version published by the Free 246 | Software Foundation. If the Program does not specify a version number of 247 | this License, you may choose any version ever published by the Free Software 248 | Foundation. 249 | 250 | 10. If you wish to incorporate parts of the Program into other free 251 | programs whose distribution conditions are different, write to the author 252 | to ask for permission. For software which is copyrighted by the Free 253 | Software Foundation, write to the Free Software Foundation; we sometimes 254 | make exceptions for this. Our decision will be guided by the two goals 255 | of preserving the free status of all derivatives of our free software and 256 | of promoting the sharing and reuse of software generally. 257 | 258 | NO WARRANTY 259 | 260 | 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY 261 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN 262 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES 263 | PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED 264 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 265 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS 266 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE 267 | PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, 268 | REPAIR OR CORRECTION. 269 | 270 | 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 271 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR 272 | REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, 273 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING 274 | OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED 275 | TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY 276 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER 277 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE 278 | POSSIBILITY OF SUCH DAMAGES. 279 | 280 | END OF TERMS AND CONDITIONS 281 | 282 | How to Apply These Terms to Your New Programs 283 | 284 | If you develop a new program, and you want it to be of the greatest 285 | possible use to the public, the best way to achieve this is to make it 286 | free software which everyone can redistribute and change under these terms. 287 | 288 | To do so, attach the following notices to the program. It is safest 289 | to attach them to the start of each source file to most effectively 290 | convey the exclusion of warranty; and each file should have at least 291 | the "copyright" line and a pointer to where the full notice is found. 292 | 293 | Apple IIgs Assembly Language Crash Course 294 | Copyright (C) 2013 Dagen Brock 295 | 296 | This program is free software; you can redistribute it and/or modify 297 | it under the terms of the GNU General Public License as published by 298 | the Free Software Foundation; either version 2 of the License, or 299 | (at your option) any later version. 300 | 301 | This program is distributed in the hope that it will be useful, 302 | but WITHOUT ANY WARRANTY; without even the implied warranty of 303 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 304 | GNU General Public License for more details. 305 | 306 | You should have received a copy of the GNU General Public License along 307 | with this program; if not, write to the Free Software Foundation, Inc., 308 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 309 | 310 | Also add information on how to contact you by electronic and paper mail. 311 | 312 | If the program is interactive, make it output a short notice like this 313 | when it starts in an interactive mode: 314 | 315 | Gnomovision version 69, Copyright (C) year name of author 316 | Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 317 | This is free software, and you are welcome to redistribute it 318 | under certain conditions; type `show c' for details. 319 | 320 | The hypothetical commands `show w' and `show c' should show the appropriate 321 | parts of the General Public License. Of course, the commands you use may 322 | be called something other than `show w' and `show c'; they could even be 323 | mouse-clicks or menu items--whatever suits your program. 324 | 325 | You should also get your employer (if you work as a programmer) or your 326 | school, if any, to sign a "copyright disclaimer" for the program, if 327 | necessary. Here is a sample; alter the names: 328 | 329 | Yoyodyne, Inc., hereby disclaims all copyright interest in the program 330 | `Gnomovision' (which makes passes at compilers) written by James Hacker. 331 | 332 | {signature of Ty Coon}, 1 April 1989 333 | Ty Coon, President of Vice 334 | 335 | This General Public License does not permit incorporating your program into 336 | proprietary programs. If your program is a subroutine library, you may 337 | consider it more useful to permit linking proprietary applications with the 338 | library. If this is what you want to do, use the GNU Lesser General 339 | Public License instead of this License. 340 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | gslib 2 | ===== 3 | 4 | Apple IIgs Assembly Language Crash Course 5 | 6 | 7 | Source Files in "Lesson" Order 8 | 9 | 10 | * quit.s Quit, Old-School simple quit program 11 | * quit8.s Quit8.System, ProDOS8 simple quit program 12 | * quit16.s Quit16, GSOS/P16 simple quit program 13 | * shr1.s SHR1, Shows how to turn on SHR Graphics Mode and clear screen 14 | * shr2.s SHR2, Adds functions to write palettes, clear screen to color, set scan-line control bytes 15 | * font.s Font routines, this is a library you can include to draw text 16 | * shrhello.s "Hello World", Example program showing how to use the font routines 17 | * shrloadimg.s SHRLoadImage, Loads a PackBytes image and unpacks it to screen 18 | * shrloadimg.m.s macros for ToolBox calls in SHRLoadImage 19 | -------------------------------------------------------------------------------- /appy.yaml: -------------------------------------------------------------------------------- 1 | assemble: 2 | - source/quit.s 3 | - source/quit8.s 4 | - source/quit16.s 5 | - source/shr1.s 6 | - source/shr2.s 7 | - source/shrhello.s 8 | - source/shrloadimg.s 9 | - source/demo.s 10 | assembleflags: "-V" 11 | # formatflags: "mc:10 oc:14 cc:30 ms:1 bs:2" 12 | # additional files to indent along with above 13 | indent: 14 | - source/shrloadimg.m.s 15 | - source/gslib.mac.s 16 | - source/skel.macgen.s 17 | disks: 18 | - name: gslibdemo 19 | file: gslibdemo800.2mg 20 | size: 800KB 21 | files: 22 | - input: source/quit 23 | output: /gslibdemo 24 | - input: source/quit8.system 25 | output: /gslibdemo 26 | - input: source/Quit.Sys16 27 | output: /gslibdemo 28 | - input: source/SHR1.Sys16 29 | output: /gslibdemo 30 | - input: source/SHR2.Sys16 31 | output: /gslibdemo 32 | - input: source/SHRHello.Sys16 33 | output: /gslibdemo 34 | - input: source/SHRLoadImage.S16 35 | output: /gslibdemo 36 | 37 | -------------------------------------------------------------------------------- /content/KFEST2013B.PAK: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/digarok/gslib/19eeebe8bddccac92e94b5646242bf441c4d5ba6/content/KFEST2013B.PAK -------------------------------------------------------------------------------- /content/song3.nt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/digarok/gslib/19eeebe8bddccac92e94b5646242bf441c4d5ba6/content/song3.nt -------------------------------------------------------------------------------- /content/torus00.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/digarok/gslib/19eeebe8bddccac92e94b5646242bf441c4d5ba6/content/torus00.bin -------------------------------------------------------------------------------- /documentation/CrashCourse.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/digarok/gslib/19eeebe8bddccac92e94b5646242bf441c4d5ba6/documentation/CrashCourse.pdf -------------------------------------------------------------------------------- /documentation/GS Video Layout.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/digarok/gslib/19eeebe8bddccac92e94b5646242bf441c4d5ba6/documentation/GS Video Layout.pdf -------------------------------------------------------------------------------- /documentation/GS Video Registers.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/digarok/gslib/19eeebe8bddccac92e94b5646242bf441c4d5ba6/documentation/GS Video Registers.pdf -------------------------------------------------------------------------------- /source/demo.s: -------------------------------------------------------------------------------- 1 | *--------------------------------------* 2 | * Graphics and Sound Library Example * 3 | * * 4 | * Dagen Brock * 5 | * 2013-06-10 * 6 | *--------------------------------------* 7 | 8 | rel 9 | dsk demo.sys16.l 10 | typ $B3 11 | use gslib.mac 12 | use skel.macgen 13 | lst off 14 | 15 | *--------------------------------------* 16 | * Basic Error Macro * 17 | *--------------------------------------* 18 | _Err mac 19 | bcc NoErr 20 | do ]0 ; (DO if true) 21 | jsr PgmDeath ; this is conditionally compiled if 22 | str ]1 ; we pass in an error statement 23 | else ; (ELSE) 24 | jmp PgmDeath0 ; we just call the simpler error handler 25 | fin ; (FIN) 26 | NoErr eom 27 | 28 | *--------------------------------------* 29 | * Initialize environment * 30 | *--------------------------------------* 31 | Start clc 32 | xce 33 | rep $30 ; set full 16-bit mode 34 | 35 | phk ; set bank - always do this at 36 | plb ; the beginning of a GSOS program 37 | 38 | * tsc ; not sure about this? 39 | * sec 40 | * sbc #$10 41 | * tcs 42 | * inc 43 | * tcd 44 | 45 | 46 | _TLStartUp ; normal tool initialization 47 | pha 48 | _MMStartUp 49 | _Err ; should never happen 50 | pla 51 | sta MasterId ; our master handle references the memory allocated to us 52 | ora #$0100 ; 53 | sta UserId ; any memory we request must use our own id 54 | 55 | 56 | 57 | *--------------------------------------* 58 | * Initialize graphics * 59 | *--------------------------------------* 60 | jsr AllocOneBank ; Alloc 64KB for Load/Unpack 61 | sta BankLoad ; Store "Bank Pointer" 62 | 63 | ldx #ImageName ; Load+Unpack Boot Picture 64 | jsr LoadPicture ; X=Name, A=Bank to use for loading 65 | 66 | jsr AllocOneBank ; Alloc 64KB for Sprite binary data 67 | sta BankSprite ; Store "Bank Pointer" 68 | sta torusBank00+2 69 | 70 | ldx #Sprite00Name ; Pointer to filename 71 | lda BankSprite ; "Bank Pointer" to sprite memory 72 | jsr LoadFile ; Load File 73 | 74 | 75 | 76 | *--------------------------------------* 77 | * Initialize sound * 78 | *--------------------------------------* 79 | 80 | pea #0220 ; Tool220 81 | pea $0105 ; Version Min 82 | ldx #$0F01 ; LoadOneTool 83 | jsl $E10000 84 | _Err "Tool220 (min v1.05) not Found! : $" 85 | 86 | PushLong #0 ; Allocate Direct Page in Bank 00 87 | PushLong #$000100 88 | PushWord UserId 89 | PushWord #$C001 ; Allocation parms 90 | PushLong #0 91 | _NewHandle 92 | _Err "Can't Allocate ZPage! : $" 93 | pla 94 | sta $00 95 | pla 96 | sta $02 97 | 98 | lda [$00] ; PageZero 99 | pha 100 | _NTStartUp 101 | _Err 102 | 103 | lda #ModuleName 104 | ldx #^ModuleName 105 | jsr ReadFile 106 | _Err "Module Not Found! : $" 107 | 108 | pei $06 ; ^@ModuleAdr 109 | pei $04 ; @ModuleAdr (Must be Page aligned !!!) 110 | ldx #$09DC ; NTInitMusic 111 | jsl $E10000 112 | _Err 113 | 114 | _NTLaunchMusic 115 | _Err 116 | 117 | ;; here? 118 | jsr StartGraphicMode ; Display Graphic Page, activate Shadowing... 119 | 120 | lda BankLoad ; Display Boot Picture 121 | clc 122 | adc #$0080 ; offset by 128 bytes? 123 | jsr FadeIn ; A=XX/YY00 of the image 124 | ;; to here 125 | 126 | 127 | stal $E1C010 128 | 129 | MainLoop 130 | :vbl ldal $E1C02E ; vblank - move it 131 | and #$00FF 132 | cmp #$00D0 133 | bne :vbl 134 | 135 | 136 | 137 | jsr UpdateDemoState 138 | jsr HandleDemoState 139 | 140 | pha 141 | ldx #$0BDC ; NTUpdateSound 142 | jsl $E10000 143 | _Err 144 | pla ; EndOfMusic (0,1 or -1) 145 | 146 | **** 147 | 148 | cmp #1 149 | bcs EndMusic 150 | jsr MouseClick ; Exit ? 151 | bcs EndMusic 152 | ldal $E1BFFF 153 | bpl MainLoop 154 | 155 | EndMusic jsr ExitGraphic 156 | _NTStopMusic 157 | _Err 158 | _NTShutDown 159 | _Err 160 | lda UserId 161 | pha 162 | ldx #$1102 ; Dispose All 163 | jsl $E10000 164 | _Err 165 | lda MasterId 166 | pha 167 | _MMShutDown 168 | _Err 169 | 170 | jsl $E100A8 171 | da $0029 172 | adrl QuitParm 173 | 174 | QuitParm da 0 175 | adrl 0 176 | da 0 177 | 178 | MasterId ds 2 179 | UserId ds 2 180 | 181 | ExitGraphic lda #$0 182 | ldx #$7cfe 183 | :loop stal $e12000,x 184 | dex 185 | dex 186 | bpl :loop 187 | lda #Str9 188 | ldx #0 189 | jsr DrawString 190 | rts 191 | 192 | DemoCounter hex 0000 193 | RepeatIndex hex 0000 ; stupid frame skip mechanism 194 | TorusLoc1 equ #160*70+5+$2000 195 | TorusLoc2 equ #160*70+14+$2000 196 | TorusLoc3 equ #160*70+22+$2000 197 | 198 | Torii dw #07 199 | TorusLocs dw #160*70+5+$2000+10 200 | dw #160*70+25+$2000+10 201 | dw #160*70+45+$2000+10 202 | dw #160*70+65+$2000+10 203 | dw #160*70+85+$2000+10 204 | dw #160*70+105+$2000+10 205 | dw #160*70+125+$2000+10 206 | TorusFrames dw #00 207 | dw #10 208 | dw #08 209 | dw #16 210 | dw #20 211 | dw #30 212 | dw #44 213 | 214 | 215 | 216 | UndrawTorii 217 | ldx Torii 218 | :nextUndraw dex ;switch natural number to 0-index 219 | phx 220 | 221 | txa 222 | asl 223 | tax 224 | lda TorusLocs,x 225 | tay 226 | lda #60 227 | jsr Drawtorus ;blackout 228 | plx 229 | cpx #$0 ;done? 230 | bne :nextUndraw 231 | rts 232 | 233 | DrawTorii 234 | ldx Torii 235 | :next dex ;switch natural number to 0-index 236 | phx 237 | 238 | txa 239 | asl 240 | tax 241 | lda TorusLocs,x 242 | tay 243 | lda TorusFrames,x 244 | jsr Drawtorus 245 | plx 246 | cpx #$0 ;done drawing all torii 247 | bne :next 248 | rts 249 | 250 | UpdateTorii 251 | ldy Torii 252 | :nextUpdate dey ;switch natural number to 0-index 253 | 254 | tya 255 | asl 256 | tax 257 | lda TorusFrames,x 258 | inc 259 | cmp #60 ;reset frame counter 260 | bne :not 261 | lda #$0 262 | :not sta TorusFrames,x 263 | 264 | cpy #$0 265 | bne :nextUpdate 266 | rts 267 | 268 | UpdateSprite 269 | jsr UndrawTorii 270 | 271 | jsr DrawTorii 272 | 273 | inc RepeatIndex ; ghetto fram skip 274 | lda RepeatIndex 275 | cmp #04 276 | bne :noAdvance 277 | stz RepeatIndex 278 | ;; do stuff 279 | jsr UpdateTorii 280 | :noAdvance 281 | :done rts 282 | 283 | 284 | ScrollTop equ $e12000+#160*80 285 | Scroll 286 | ldx #$00 287 | ldy #158 288 | :scloop ldal ScrollTop+2,x ;#80*160 289 | stal ScrollTop,x 290 | ldal ScrollTop+2+160,x ;2 291 | stal ScrollTop+160,x 292 | ldal ScrollTop+2+320,x ;3 293 | stal ScrollTop+320,x 294 | ldal ScrollTop+2+480,x ;4 295 | stal ScrollTop+480,x 296 | ldal ScrollTop+2+640,x ;5 297 | stal ScrollTop+640,x 298 | ldal ScrollTop+2+800,x ;6 299 | stal ScrollTop+800,x 300 | * ldal ScrollTop+2+960,x ;7 301 | * stal ScrollTop+960,x 302 | * ldal ScrollTop+2+1120,x ;7 303 | * stal ScrollTop+1120,x 304 | * ldal ScrollTop+2+1280,x ;7 305 | * stal ScrollTop+1280,x 306 | * ldal ScrollTop+2+1440,x ;7 307 | * stal ScrollTop+1440,x 308 | * ldal ScrollTop+2+1600,x ;7 309 | * stal ScrollTop+1600,x 310 | * ldal ScrollTop+2+1760,x ;7 311 | * stal ScrollTop+1760,x 312 | * ldal ScrollTop+2+1920,x ;7 313 | * stal ScrollTop+1920,x 314 | * ldal ScrollTop+2+2080,x ;7 315 | * stal ScrollTop+2080,x 316 | * ldal ScrollTop+2+2240,x ;7 317 | * stal ScrollTop+2240,x 318 | * ldal ScrollTop+2+2400,x ;7 319 | * stal ScrollTop+2400,x 320 | * ldal ScrollTop+2+2560,x ;7 321 | * stal ScrollTop+2560,x 322 | * ldal ScrollTop+2+2720,x ;7 323 | * stal ScrollTop+2720,x 324 | * ldal ScrollTop+2+2880,x ;7 325 | * stal ScrollTop+2880,x 326 | * ldal ScrollTop+2+3040,x ;7 327 | * stal ScrollTop+3040,x 328 | inx 329 | inx 330 | dey 331 | dey 332 | beq :done 333 | brl :scloop 334 | :done rts 335 | 336 | 337 | 338 | ReadFile sta Parm0 339 | stx Parm0+2 340 | jsl $E100A8 341 | da $10 ; Open 342 | adrl Params 343 | bcc *+3 344 | rts 345 | jsl $E100A8 346 | da $19 347 | adrl Params 348 | bcc No_ErrGetEof 349 | pha 350 | jsr Go_Close 351 | pla 352 | sec 353 | rts 354 | No_ErrGetEof pha 355 | pha 356 | lda Parm0+2 357 | sta Parm1+2 358 | pha 359 | lda Parm0 360 | sta Parm1 361 | pha 362 | lda UserId 363 | pha 364 | pea $C00C ; Page Aligned!!! 365 | pea $0 366 | pea $0 367 | ldx #$0902 ; NewHandle 368 | jsl $E10000 369 | _Err "Out Of Memory Error! : $" 370 | pla 371 | sta $00 372 | pla 373 | sta $02 374 | ldy #2 375 | lda [$00],Y 376 | sta Parm0+2 377 | tax 378 | lda [$00] 379 | sta Parm0 380 | sta $04 381 | stx $06 382 | jsl $E100A8 383 | da $12 ; Read 384 | adrl Params 385 | bcc Go_Close 386 | pha 387 | pei $02 ; Free mem 388 | pei $00 389 | ldx #$1002 ; Dispose 390 | jsl $E10000 391 | _Err 392 | jsr Go_Close 393 | pla 394 | sec 395 | rts 396 | Go_Close jsl $E100A8 397 | da $14 ; Close 398 | adrl Params 399 | rts 400 | 401 | Params da 0 402 | Parm0 adrl 0 403 | Parm1 adrl 0 404 | adrl 0 405 | 406 | *------------------------------------------------- 407 | PgmDeath tax 408 | pla 409 | inc 410 | phx 411 | phk 412 | pha 413 | bra ContDeath 414 | PgmDeath0 pha 415 | pea $0000 416 | pea $0000 417 | ContDeath ldx #$1503 418 | jsl $E10000 419 | 420 | ** SPRITE / PIC / MEMORY STUFF 421 | 422 | BankLoad hex 0000 ; used for Load/Unpack 423 | BankSprite hex 0000 424 | StackAddress hex 0000 425 | ImageName strl '1/KFEST2013B.PAK' 426 | Sprite00Name strl '1/torus00.bin' 427 | ModuleName str 'SONG3.NT' ; Module to be played 428 | 429 | ***** 430 | * NEW NEW NEW 431 | * NEWNEW 432 | ***** 433 | 434 | Str1 str 'GREETINGS FROM KANSASFEST' ;30 435 | Str2 str 'GREETINGS TO OZKFEST' ;40 436 | Str3 str 'SORRY IT',27,'S NOT A BIGGER DEMO' ;24 437 | 438 | Str4 str 'THANKS TO BRUTAL DELUXE' ;34 439 | Str6 str 'THANKS TO KFEST STAFF & ATTENDEES!' ;14 440 | Str5 str 'MEGA THANKS TO YOU THE VIEWER!!' ;26 441 | Str7 str 'OK... I',27,'M TIRED ;)' ;42 442 | Str8 str 'DIGAROK - 2013' ;52 443 | Str9 str 'THAT',27,'S ALL FOLKS' 444 | 445 | MODE_NOP equ 0000 446 | MODE_TORUS equ 0001 447 | MODE_STR1 equ 0002 448 | MODE_STR2 equ 0003 449 | MODE_SCROLL equ 0009 450 | 451 | MODE dw 0000 452 | seconds equ #60 453 | 454 | UpdateDemoState 455 | inc DemoCounter 456 | lda DemoCounter 457 | 458 | 459 | * Draw Str1 460 | cmp #3*seconds-5 461 | bne :next1 462 | lda #Str1 ;draw str1 @ 2 second 463 | ldx #80*160+30 464 | jsr DrawString 465 | lda #MODE_NOP 466 | sta MODE 467 | rts 468 | 469 | :next1 cmp #5*seconds-20 ;start scroll at 3 second 470 | bne :next2 471 | lda #MODE_SCROLL 472 | sta MODE 473 | rts 474 | 475 | :next2 cmp #7*seconds ;draw torii 476 | bne :next3a 477 | lda #MODE_TORUS 478 | sta MODE 479 | rts 480 | :next3a cmp #14*seconds 481 | bne :next3 482 | 483 | lda #MODE_NOP 484 | sta MODE 485 | jsr UndrawTorii 486 | rts 487 | 488 | :next3 cmp #15*seconds+30 ;second message 489 | bne :next4 490 | 491 | lda #Str2 ;draw str1 @ 2 second 492 | ldx #80*160+40 493 | jsr DrawString 494 | rts 495 | 496 | :next4 cmp #18*seconds+30 ;scroll off message 497 | bne :next5 498 | lda #MODE_SCROLL 499 | sta MODE 500 | rts 501 | 502 | :next5 cmp #20*seconds 503 | bne :next6 504 | 505 | lda #Str3 506 | ldx #80*160+24 507 | jsr DrawString 508 | lda #MODE_NOP 509 | sta MODE 510 | rts 511 | 512 | :next6 cmp #22*seconds 513 | bne :next7 514 | lda #MODE_SCROLL 515 | sta MODE 516 | rts 517 | :next7 cmp #23*seconds+30 ;draw torii 518 | bne :next8a 519 | lda #MODE_TORUS 520 | sta MODE 521 | rts 522 | :next8a cmp #26*seconds+45 523 | bne :next8 524 | jsr UndrawTorii 525 | lda #MODE_NOP 526 | sta MODE 527 | rts 528 | 529 | 530 | :next8 531 | cmp #27*seconds 532 | bne :next8scroll 533 | lda #Str4 534 | ldx #80*160+34 535 | jsr DrawString 536 | rts 537 | :next8scroll 538 | cmp #29*seconds 539 | bne :next9 540 | lda #MODE_SCROLL 541 | sta MODE 542 | rts 543 | 544 | :next9 545 | cmp #30*seconds+30 546 | bne :next9scroll 547 | lda #Str5 548 | ldx #80*160+14 549 | jsr DrawString 550 | lda #MODE_NOP 551 | sta MODE 552 | rts 553 | :next9scroll 554 | cmp #33*seconds 555 | bne :next10 556 | lda #MODE_SCROLL 557 | sta MODE 558 | rts 559 | 560 | 561 | :next10 562 | cmp #34*seconds+30 563 | bne :next10scroll 564 | lda #Str6 565 | ldx #80*160+20 566 | jsr DrawString 567 | lda #MODE_NOP 568 | sta MODE 569 | rts 570 | :next10scroll 571 | cmp #36*seconds 572 | bne :next11 573 | lda #MODE_SCROLL 574 | sta MODE 575 | rts 576 | 577 | 578 | :next11 579 | cmp #37*seconds+30 580 | bne :next11scroll 581 | lda #Str7 582 | ldx #80*160+42 583 | jsr DrawString 584 | lda #MODE_NOP 585 | sta MODE 586 | rts 587 | :next11scroll 588 | cmp #40*seconds 589 | bne :next12 590 | lda #MODE_SCROLL 591 | sta MODE 592 | rts 593 | 594 | :next12 595 | cmp #41*seconds+30 596 | bne :next12scroll 597 | lda #Str8 598 | ldx #80*160+52 599 | jsr DrawString 600 | lda #MODE_NOP 601 | sta MODE 602 | rts 603 | :next12scroll 604 | cmp #46*seconds 605 | bne :next13 606 | lda #MODE_SCROLL 607 | sta MODE 608 | rts 609 | :next13 610 | cmp #48*seconds+30 611 | bne :next14 612 | lda #MODE_TORUS 613 | sta MODE 614 | :next14 615 | rts 616 | 617 | HandleDemoState 618 | lda MODE 619 | cmp #MODE_NOP 620 | bne :next1 621 | rts 622 | 623 | :next1 cmp #MODE_TORUS 624 | bne :next2 625 | jsr UpdateSprite ;does whole torus line. get it? haahah 626 | rts 627 | 628 | :next2 cmp #MODE_SCROLL 629 | bne :next3 630 | jsr Scroll 631 | 632 | rts 633 | 634 | :next3 635 | rts 636 | 637 | 638 | 639 | 640 | *--------------------------------------* 641 | * GS/OS File Loading Routines * 642 | *--------------------------------------* 643 | GSOS = $E100A8 644 | 645 | LoadFile stx gsosOPEN+4 ; X=File, A=Bank XX/00 646 | sta gsosREAD+5 647 | 648 | :openFile jsl GSOS ; Open File 649 | dw $2010 650 | adrl gsosOPEN 651 | bcs :openReadErr 652 | lda gsosOPEN+2 653 | sta gsosGETEOF+2 654 | sta gsosREAD+2 655 | 656 | jsl GSOS ; Get File Size 657 | dw $2019 658 | adrl gsosGETEOF 659 | lda gsosGETEOF+4 660 | sta gsosREAD+8 661 | lda gsosGETEOF+6 662 | sta gsosREAD+10 663 | 664 | jsl GSOS ; Read File Content 665 | dw $2012 666 | adrl gsosREAD 667 | bcs :openReadErr 668 | 669 | :closeFile jsl GSOS ; Close File 670 | dw $2014 671 | adrl gsosCLOSE 672 | clc 673 | lda gsosGETEOF+4 ; File Size 674 | rts 675 | 676 | :openReadErr jsr :closeFile 677 | nop 678 | nop 679 | 680 | PushWord #0 681 | PushLong #msgLine1 682 | PushLong #msgLine2 683 | PushLong #msgLine3 684 | PushLong #msgLine4 685 | ; _TLTextMountVolume 686 | ; TODO 687 | pla 688 | cmp #1 689 | bne LF_Err1 690 | brl :openFile 691 | LF_Err1 sec 692 | rts 693 | 694 | msgLine1 str 'Unable to load File' 695 | msgLine2 str 'Press a key :' 696 | msgLine3 str ' -> Return to Try Again' 697 | msgLine4 str ' -> Esc to Quit' 698 | 699 | *------- 700 | 701 | Exit jsl GSOS 702 | dw $2029 703 | adrl gsosQUIT 704 | 705 | *------- 706 | 707 | gsosOPEN dw 2 ; pCount 708 | ds 2 ; refNum 709 | adrl ImageName ; pathname 710 | 711 | gsosGETEOF dw 2 ; pCount 712 | ds 2 ; refNum 713 | ds 4 ; eof 714 | 715 | gsosREAD dw 4 ; pCount 716 | ds 2 ; refNum 717 | ds 4 ; dataBuffer 718 | ds 4 ; requestCount 719 | ds 4 ; transferCount 720 | 721 | gsosCLOSE dw 1 ; pCount 722 | ds 2 ; refNum 723 | 724 | gsosQUIT dw 2 ; pCount 725 | ds 4 ; pathname 726 | ds 2 ; flags 727 | 728 | 729 | 730 | *--------------------------------------* 731 | * Graphics Helpers * 732 | *--------------------------------------* 733 | LoadPicture jsr LoadFile ; X=Nom Image, A=Banc de chargement XX/00 734 | bcc :loadOK 735 | brl Exit 736 | :loadOK jsr UnpackPicture ; A=Packed Size 737 | rts 738 | 739 | 740 | UnpackPicture sta UP_PackedSize ; Size of Packed Data 741 | lda #$8000 ; Size of output Data Buffer 742 | sta UP_UnPackedSize 743 | lda BankLoad ; Banc de chargement / Decompression 744 | sta UP_Packed+1 ; Packed Data 745 | clc 746 | adc #$0080 747 | stz UP_UnPacked ; On remet a zero car modifie par l'appel 748 | stz UP_UnPacked+2 749 | sta UP_UnPacked+1 ; Unpacked Data buffer 750 | 751 | PushWord #0 ; Space for Result : Number of bytes unpacked 752 | PushLong UP_Packed ; Pointer to buffer containing the packed data 753 | PushWord UP_PackedSize ; Size of the Packed Data 754 | PushLong #UP_UnPacked ; Pointer to Pointer to unpacked buffer 755 | PushLong #UP_UnPackedSize ; Pointer to a Word containing size of unpacked data 756 | _UnPackBytes 757 | pla ; Number of byte unpacked 758 | rts 759 | 760 | UP_Packed hex 00000000 ; Address of Packed Data 761 | UP_PackedSize hex 0000 ; Size of Packed Data 762 | UP_UnPacked hex 00000000 ; Address of Unpacked Data Buffer (modified) 763 | UP_UnPackedSize hex 0000 ; Size of Unpacked Data Buffer (modified) 764 | 765 | *--------------------------------------* 766 | * Misc Graphics Subroutines * 767 | *--------------------------------------* 768 | StartGraphicMode sep #$30 769 | lda #$41 ; Linearise la page graphique 770 | stal $00C029 771 | rep #$30 772 | 773 | ldx #$7FFE ; Efface l'Ecran 774 | lda #$0000 775 | SGM_1 stal $E12000,X 776 | dex 777 | dex 778 | bpl SGM_1 779 | 780 | sep #$30 781 | 782 | lda #$F0 ; Fond Noir 783 | stal $00C022 784 | lda #$00 785 | stal $00C034 ; Bordure Noire 786 | 787 | lda #$A1 ; Affiche la page graphique 788 | stal $00C029 789 | 790 | lda #$00 ; Active le Shadowing 791 | stal $00C035 792 | rep #$30 793 | rts 794 | 795 | *-------------- 796 | 797 | FadeIn sta FI_00+2 ; A=XX/YY00 de l'image 798 | clc 799 | adc #$007E 800 | sta FI_3+2 801 | sta FI_5+2 802 | sta FI_7+2 803 | 804 | ldx #$01FE 805 | lda #$0000 ; NETTOYAGE PREALABLE DES PALETTES en $01/2000 806 | FI_0 stal $019E00,X 807 | dex 808 | dex 809 | bpl FI_0 810 | 811 | ldx #$7DFE ; RECOPIE LES POINTS + SCB en $01/2000 812 | FI_00 ldal $000000,X 813 | stal $012000,X 814 | dex 815 | dex 816 | bpl FI_00 817 | 818 | ldy #$000F ; ON FAIT UN FADE IN SUR LES 16 PALETTES 819 | FI_1 ldx #$01FE 820 | 821 | FI_2 ldal $019E00,X ; COMPOSANTE BLEUE 822 | and #$000F 823 | sta FI_33+1 824 | FI_3 ldal $06FE00,X 825 | and #$000F 826 | FI_33 cmp #$0000 827 | beq FI_4 828 | ldal $019E00,X 829 | clc 830 | adc #$0001 831 | stal $019E00,X 832 | 833 | FI_4 ldal $019E00,X ; COMPOSANTE VERTE 834 | and #$00F0 835 | sta FI_55+1 836 | FI_5 ldal $06FE00,X 837 | and #$00F0 838 | FI_55 cmp #$0000 839 | beq FI_6 840 | ldal $019E00,X 841 | clc 842 | adc #$0010 843 | stal $019E00,X 844 | 845 | FI_6 ldal $019E00,X ; COMPOSANTE ROUGE 846 | and #$0F00 847 | sta FI_77+1 848 | FI_7 ldal $06FE00,X 849 | and #$0F00 850 | FI_77 cmp #$0000 851 | beq FI_8 852 | ldal $019E00,X 853 | clc 854 | adc #$0100 855 | stal $019E00,X 856 | 857 | FI_8 dex 858 | dex 859 | bpl FI_2 860 | jsr WaitForVBL ; TEMPO 861 | jsr WaitForVBL 862 | dey 863 | bpl FI_1 864 | rts 865 | 866 | *-------------- 867 | 868 | FadeOut ldy #$000F ; Fade Out de l'Ecran 01/2000 869 | FO_0 ldx #$01FE 870 | 871 | FO_1 ldal $E19E00,X ; COMPOSANTE BLEUE 872 | and #$000F 873 | beq FO_2 874 | ldal $E19E00,X 875 | sec 876 | sbc #$0001 877 | stal $E19E00,X 878 | 879 | FO_2 ldal $E19E00,X ; COMPOSANTE VERTE 880 | and #$00F0 881 | beq FO_3 882 | ldal $E19E00,X 883 | sec 884 | sbc #$0010 885 | stal $E19E00,X 886 | 887 | FO_3 ldal $E19E00,X ; COMPOSANTE ROUGE 888 | and #$0F00 889 | beq FO_4 890 | ldal $E19E00,X 891 | sec 892 | sbc #$0100 893 | stal $E19E00,X 894 | 895 | FO_4 dex 896 | dex 897 | bpl FO_1 898 | dey 899 | jsr WaitForVBL ; TEMPO 900 | jsr WaitForVBL 901 | bpl FO_0 902 | rts 903 | 904 | *-------------- 905 | 906 | WaitForVBL sep #$30 ; Wait fr VBL 907 | :wait1 ldal $00C019 908 | bmi :wait1 909 | :wait2 ldal $00C019 910 | bpl :wait2 911 | rep #$30 912 | rts 913 | 914 | 915 | 916 | *--------------------------------------* 917 | * Misc Subroutines and helpers * 918 | *--------------------------------------* 919 | WaitForKey sep #$30 920 | :wait ldal $00c000 921 | bpl :wait 922 | stal $00c010 923 | rep #$30 924 | rts 925 | 926 | 927 | MouseClick clc ; BOUTON SOURIS ENFONCE ? 928 | ldal $E0C026 929 | bmi MC_1 930 | rts 931 | MC_1 ldal $E0C023 932 | ldal $E0C023 933 | bpl MC_2 934 | rts 935 | MC_2 sec 936 | rts 937 | 938 | 939 | *--------------------------------------* 940 | * Memory allocation routines * 941 | *--------------------------------------* 942 | 943 | *--------------------------------------* 944 | * AllocOneBank * 945 | * This is a custom allocation function * 946 | * that makes use of the fact that we * 947 | * request an entire locked bank and so * 948 | * simply returns the bank in the * 949 | * accumulator. (basically dereference * 950 | * the Handle to get the pointer) * 951 | *--------------------------------------* 952 | AllocOneBank PushLong #0 953 | PushLong #$10000 954 | PushWord UserId 955 | PushWord #%11000000_00011100 956 | PushLong #0 957 | _NewHandle ; returns LONG Handle on stack 958 | plx ; base address of the new handle 959 | pla ; high address 00XX of the new handle (bank) 960 | xba ; swab accumulator bytes to XX00 961 | sta :bank+2 ; store as bank for next op (overwrite $XX00) 962 | :bank ldal $000001,X ; recover the bank address in A=XX/00 963 | rts 964 | 965 | *--------------------------------------* 966 | * Subroutine Includes * 967 | *--------------------------------------* 968 | use TORUS 969 | use FONT 970 | 971 | lst on 972 | -------------------------------------------------------------------------------- /source/font.s: -------------------------------------------------------------------------------- 1 | **************************************** 2 | * FONT ENGINE (v3?) * 3 | * * 4 | * Dagen Brock * 5 | * 2013-07-20 * 6 | **************************************** 7 | * Note that this is not particularly * 8 | * optimized. But it's meant to be a * 9 | * straightforward implementation that * 10 | * is easy to understand. * 11 | **************************************** 12 | * A= ptr to string preceded by length * 13 | * X= screen location * 14 | **************************************** 15 | ; each char: 16 | ; draw char at loc 17 | ; update loc 18 | ; see if length hit - no? back to draw char 19 | mx %00 20 | ]F_Length ds 2 ;length of string (only one byte currently used) 21 | ]F_CharIdx ds 2 ;index of current character 22 | ]F_CurrentPos ds 2 ;current top left char position 23 | ]F_StrPtr equ $00 ;pointer to string (including length byte) / DP 24 | 25 | 26 | DrawString sta ]F_StrPtr ;store at dp 0 ($00) for indirect loads 27 | stx ]F_CurrentPos 28 | stz ]F_CharIdx 29 | lda (]F_StrPtr) 30 | and #$00ff ;strip off first char (len is only one byte) 31 | sta ]F_Length ;get our length byte 32 | 33 | NextChar lda ]F_CharIdx 34 | cmp ]F_Length 35 | bne :notDone 36 | rts ;DONE! Return to caller 37 | 38 | :notDone inc ]F_CharIdx 39 | ldy ]F_CharIdx 40 | lda ($00),y ;get next char! 41 | and #$00FF ;mask high byte 42 | sec 43 | sbc #' ' ;our table starts with space ' ' 44 | asl ;*2 45 | tay 46 | ldx ]F_CurrentPos 47 | jsr :drawChar 48 | inc ]F_CurrentPos ;compare to addition time (?) 49 | inc ]F_CurrentPos 50 | inc ]F_CurrentPos 51 | inc ]F_CurrentPos ;update screen pos (2 words=8 pixels) 52 | bra NextChar 53 | 54 | ;x = TopLeft screen pos 55 | ;y = char table offset 56 | :drawChar lda FontTable,y ;get real address of char data 57 | sec 58 | sbc #FontData ;pivot offset - now a is offset of fontdata 59 | tay ;so we'll index with that 60 | lda FontData,y 61 | stal $E12000,x 62 | lda FontData+2,y 63 | stal #2+$E12000,x 64 | lda FontData+4,y 65 | stal #160+$E12000,x 66 | lda FontData+6,y 67 | stal #160+2+$E12000,x 68 | lda FontData+8,y 69 | stal #160*2+$E12000,x 70 | lda FontData+10,y 71 | stal #160*2+2+$E12000,x 72 | lda FontData+12,y 73 | stal #160*3+$E12000,x 74 | lda FontData+14,y 75 | stal #160*3+2+$E12000,x 76 | lda FontData+16,y 77 | stal #160*4+$E12000,x 78 | lda FontData+18,y 79 | stal #160*4+2+$E12000,x 80 | lda FontData+20,y 81 | stal #160*5+$E12000,x 82 | lda FontData+22,y 83 | stal #160*5+2+$E12000,x 84 | rts 85 | 86 | 87 | 88 | 89 | 90 | FontTable dw s_Space 91 | dw s_Exclaim 92 | dw s_Quote 93 | dw s_Number 94 | dw s_Dollar 95 | dw s_Percent 96 | dw s_Amper 97 | dw s_Single 98 | dw s_OpenParen 99 | dw s_CloseParen 100 | dw s_Asterix 101 | dw s_Plus 102 | dw s_Comma 103 | dw s_Minus 104 | dw s_Period 105 | dw s_Slash 106 | dw s_N0 107 | dw s_N1 108 | dw s_N2 109 | dw s_N3 110 | dw s_N4 111 | dw s_N5 112 | dw s_N6 113 | dw s_N7 114 | dw s_N8 115 | dw s_N9 116 | dw s_Colon 117 | dw s_Semi 118 | dw s_LAngle 119 | dw s_Equal 120 | dw s_RAngle 121 | dw s_Question 122 | dw s_At 123 | dw s_A 124 | dw s_B 125 | dw s_C 126 | dw s_D 127 | dw s_E 128 | dw s_F 129 | dw s_G 130 | dw s_H 131 | dw s_I 132 | dw s_J 133 | dw s_K 134 | dw s_L 135 | dw s_M 136 | dw s_N 137 | dw s_O 138 | dw s_P 139 | dw s_Q 140 | dw s_R 141 | dw s_S 142 | dw s_T 143 | dw s_U 144 | dw s_V 145 | dw s_W 146 | dw s_X 147 | dw s_Y 148 | dw s_Z 149 | dw s_LBracket 150 | dw s_BackSlash 151 | dw s_RBracket 152 | dw s_Carot 153 | dw s_UnderLine 154 | 155 | FontData = * 156 | s_Space hex 00000000 157 | hex 00000000 158 | hex 00000000 159 | hex 00000000 160 | hex 00000000 161 | hex 00000000 162 | 163 | s_Exclaim hex 000FF000 164 | hex 000FF000 165 | hex 000FF000 166 | hex 000FF000 167 | hex 00000000 168 | hex 000FF000 169 | 170 | s_Quote hex 0FF00FF0 171 | hex 00F000F0 172 | hex 00000000 173 | hex 00000000 174 | hex 00000000 175 | hex 00000000 176 | 177 | s_Number hex 00000000 178 | hex 00F00F00 179 | hex 0FFFFFF0 180 | hex 00F00F00 181 | hex 0FFFFFF0 182 | hex 00F00F00 183 | 184 | s_Dollar hex 000F0F00 185 | hex 00FFFFF0 186 | hex 0F0F0F00 187 | hex 00FFFF00 188 | hex 000F0FF0 189 | hex 0FFFFF00 190 | 191 | s_Percent hex 0FF000F0 192 | hex 00000F00 193 | hex 0000F000 194 | hex 000F0000 195 | hex 00F00000 196 | hex 0F000FF0 197 | 198 | s_Amper hex 000FF000 199 | hex 00F00F00 200 | hex 0F00F000 201 | hex 00F000F0 202 | hex 0F0FFF00 203 | hex 00F0F000 204 | 205 | s_Single hex 000FF000 206 | hex 0000F000 207 | hex 00000000 208 | hex 00000000 209 | hex 00000000 210 | hex 00000000 211 | 212 | s_OpenParen hex 000FF000 213 | hex 00FF0000 214 | hex 0FF00000 215 | hex 0FF00000 216 | hex 00FF0000 217 | hex 000FF000 218 | 219 | s_CloseParen hex 000FF000 220 | hex 0000FF00 221 | hex 00000FF0 222 | hex 00000FF0 223 | hex 0000FF00 224 | hex 000FF000 225 | 226 | 227 | s_Asterix hex 00000000 228 | hex 00F0F0F0 229 | hex 000FFF00 230 | hex 00FFFFF0 231 | hex 000FFF00 232 | hex 00F0F0F0 233 | 234 | s_Plus hex 000F0000 235 | hex 000F0000 236 | hex 0FFFFF00 237 | hex 000F0000 238 | hex 000F0000 239 | hex 00000000 240 | 241 | s_Comma hex 00000000 242 | hex 00000000 243 | hex 00000000 244 | hex 00000000 245 | hex 0000FF00 246 | hex 0000F000 247 | 248 | s_Minus hex 00000000 249 | hex 00000000 250 | hex 0FFFFF00 251 | hex 00000000 252 | hex 00000000 253 | hex 00000000 254 | 255 | 256 | s_Period hex 00000000 257 | hex 00000000 258 | hex 00000000 259 | hex 00000000 260 | hex 0000FF00 261 | hex 0000FF00 262 | 263 | s_Slash hex 000000F0 264 | hex 00000F00 265 | hex 0000F000 266 | hex 000F0000 267 | hex 00F00000 268 | hex 0F000000 269 | 270 | s_N0 hex 00FFFF00 271 | hex 0F000FF0 272 | hex 0F00F0F0 273 | hex 0F0F00F0 274 | hex 0FF000F0 275 | hex 00FFFF00 276 | 277 | s_N1 hex 000F0000 278 | hex 00FF0000 279 | hex 000F0000 280 | hex 000F0000 281 | hex 000F0000 282 | hex 00FFF000 283 | 284 | s_N2 hex 00FFFF00 285 | hex 0F0000F0 286 | hex 00000F00 287 | hex 000FF000 288 | hex 00F00000 289 | hex 0FFFFFF0 290 | 291 | s_N3 hex 00FFFF00 292 | hex 000000F0 293 | hex 000FFF00 294 | hex 000000F0 295 | hex 000000F0 296 | hex 00FFFF00 297 | 298 | s_N4 hex 0000FF00 299 | hex 000F0F00 300 | hex 00F00F00 301 | hex 0FFFFFF0 302 | hex 00000F00 303 | hex 00000F00 304 | 305 | s_N5 hex 0FFFFFF0 306 | hex 0F000000 307 | hex 0FFFFF00 308 | hex 000000F0 309 | hex 0F0000F0 310 | hex 00FFFF00 311 | 312 | s_N6 hex 000FFF00 313 | hex 00F00000 314 | hex 0F000000 315 | hex 0FFFFF00 316 | hex 0F0000F0 317 | hex 00FFFFF0 318 | 319 | s_N7 hex 0FFFFFF0 320 | hex 000000F0 321 | hex 00000F00 322 | hex 0000F000 323 | hex 000F0000 324 | hex 000F0000 325 | 326 | s_N8 hex 00FFFF00 327 | hex 0F0000F0 328 | hex 00FFFF00 329 | hex 0F0000F0 330 | hex 0F0000F0 331 | hex 00FFFF00 332 | 333 | s_N9 hex 00FFFF00 334 | hex 0F0000F0 335 | hex 00FFFF00 336 | hex 0000F000 337 | hex 000F0000 338 | hex 00F00000 339 | 340 | s_Colon hex 000FF000 341 | hex 000FF000 342 | hex 00000000 343 | hex 000FF000 344 | hex 000FF000 345 | hex 00000000 346 | 347 | s_Semi hex 00000000 348 | hex 000FF000 349 | hex 000FF000 350 | hex 00000000 351 | hex 000FF000 352 | hex 000F0000 353 | 354 | s_LAngle hex 0000F000 355 | hex 000F0000 356 | hex 00F00000 357 | hex 000F0000 358 | hex 0000F000 359 | hex 00000000 360 | 361 | s_Equal hex 00000000 362 | hex 00000000 363 | hex 0FFFFF00 364 | hex 00000000 365 | hex 0FFFFF00 366 | hex 00000000 367 | 368 | s_RAngle hex 0000F000 369 | hex 00000F00 370 | hex 000000F0 371 | hex 00000F00 372 | hex 0000F000 373 | hex 00000000 374 | 375 | s_Question hex 00FFF000 376 | hex 0F000F00 377 | hex 00000F00 378 | hex 000FF000 379 | hex 00000000 380 | hex 000FF000 381 | 382 | s_At hex 00FFFF00 383 | hex 0F0000F0 384 | hex 0F00F0F0 385 | hex 0FFFF0F0 386 | hex 000000F0 387 | hex 0FFFFF00 388 | 389 | s_A hex 000FF000 390 | hex 00F00F00 391 | hex 0F0000F0 392 | hex 0FFFFFF0 393 | hex 0F0000F0 394 | hex 0F0000F0 395 | 396 | s_B hex 0FFFFF00 397 | hex 0F0000F0 398 | hex 0FFFFF00 399 | hex 0F0000F0 400 | hex 0F0000F0 401 | hex 0FFFFF00 402 | 403 | s_C hex 00FFFFF0 404 | hex 0F000000 405 | hex 0F000000 406 | hex 0F000000 407 | hex 0F000000 408 | hex 00FFFFF0 409 | 410 | s_D hex 0FFFFF00 411 | hex 0F0000F0 412 | hex 0F0000F0 413 | hex 0F0000F0 414 | hex 0F0000F0 415 | hex 0FFFFF00 416 | 417 | s_E hex 0FFFFFF0 418 | hex 0F000000 419 | hex 0FFFF000 420 | hex 0F000000 421 | hex 0F000000 422 | hex 0FFFFFF0 423 | 424 | s_F hex 0FFFFFF0 425 | hex 0F000000 426 | hex 0FFFF000 427 | hex 0F000000 428 | hex 0F000000 429 | hex 0F000000 430 | 431 | s_G hex 00FFFFF0 432 | hex 0F000000 433 | hex 0F000000 434 | hex 0F00FFF0 435 | hex 0F0000F0 436 | hex 00FFFF00 437 | 438 | s_H hex 0F0000F0 439 | hex 0F0000F0 440 | hex 0FFFFFF0 441 | hex 0F0000F0 442 | hex 0F0000F0 443 | hex 0F0000F0 444 | 445 | s_I hex 0FFFFF00 446 | hex 000F0000 447 | hex 000F0000 448 | hex 000F0000 449 | hex 000F0000 450 | hex 0FFFFF00 451 | 452 | s_J hex 000000F0 453 | hex 000000F0 454 | hex 000000F0 455 | hex 0F0000F0 456 | hex 0F0000F0 457 | hex 00FFFF00 458 | 459 | s_K hex 0F000F00 460 | hex 0F00F000 461 | hex 0FFF0000 462 | hex 0F00F000 463 | hex 0F000F00 464 | hex 0F000F00 465 | 466 | s_L hex 0F000000 467 | hex 0F000000 468 | hex 0F000000 469 | hex 0F000000 470 | hex 0F000000 471 | hex 0FFFFFF0 472 | 473 | s_M hex 0F0000F0 474 | hex 0FF00FF0 475 | hex 0F0FF0F0 476 | hex 0F0000F0 477 | hex 0F0000F0 478 | hex 0F0000F0 479 | 480 | s_N hex 0F0000F0 481 | hex 0FF000F0 482 | hex 0F0F00F0 483 | hex 0F00F0F0 484 | hex 0F000FF0 485 | hex 0F0000F0 486 | 487 | s_O hex 00FFFF00 488 | hex 0F0000F0 489 | hex 0F0000F0 490 | hex 0F0000F0 491 | hex 0F0000F0 492 | hex 00FFFF00 493 | 494 | s_P hex 0FFFFF00 495 | hex 0F0000F0 496 | hex 0FFFFF00 497 | hex 0F000000 498 | hex 0F000000 499 | hex 0F000000 500 | 501 | s_Q hex 00FFFF00 502 | hex 0F0000F0 503 | hex 0F0000F0 504 | hex 0F00F0F0 505 | hex 0F000FF0 506 | hex 00FFFFF0 507 | 508 | s_R hex 0FFFFF00 509 | hex 0F0000F0 510 | hex 0FFFFF00 511 | hex 0F000F00 512 | hex 0F0000F0 513 | hex 0F0000F0 514 | 515 | s_S hex 00FFFFF0 516 | hex 0F000000 517 | hex 00FFFF00 518 | hex 000000F0 519 | hex 000000F0 520 | hex 0FFFFF00 521 | 522 | s_T hex 0FFFFF00 523 | hex 000F0000 524 | hex 000F0000 525 | hex 000F0000 526 | hex 000F0000 527 | hex 000F0000 528 | 529 | s_U hex 0F0000F0 530 | hex 0F0000F0 531 | hex 0F0000F0 532 | hex 0F0000F0 533 | hex 0F0000F0 534 | hex 00FFFF00 535 | 536 | s_V hex 0F0000F0 537 | hex 0F0000F0 538 | hex 0F0000F0 539 | hex 0F0000F0 540 | hex 00F00F00 541 | hex 000FF000 542 | 543 | s_W hex 0F0000F0 544 | hex 0F0000F0 545 | hex 0F0000F0 546 | hex 0F0FF0F0 547 | hex 0FF00FF0 548 | hex 0F0000F0 549 | 550 | s_X hex 0F0000F0 551 | hex 00F00F00 552 | hex 000FF000 553 | hex 000FF000 554 | hex 00F00F00 555 | hex 0F0000F0 556 | 557 | s_Y hex F00000F0 558 | hex 0F000F00 559 | hex 00F0F000 560 | hex 000F0000 561 | hex 000F0000 562 | hex 000F0000 563 | 564 | s_Z hex 0FFFFFF0 565 | hex 00000F00 566 | hex 0000F000 567 | hex 000F0000 568 | hex 00F00000 569 | hex 0FFFFFF0 570 | 571 | s_LBracket hex 000FFF00 572 | hex 000F0000 573 | hex 000F0000 574 | hex 000F0000 575 | hex 000F0000 576 | hex 000FFF00 577 | 578 | s_BackSlash hex 0F000000 579 | hex 00F00000 580 | hex 000F0000 581 | hex 0000F000 582 | hex 00000F00 583 | hex 000000F0 584 | 585 | s_RBracket hex 00FFF000 586 | hex 0000F000 587 | hex 0000F000 588 | hex 0000F000 589 | hex 0000F000 590 | hex 00FFF000 591 | 592 | s_Carot hex 0000F000 593 | hex 000F0F00 594 | hex 00F000F0 595 | hex 00000000 596 | hex 00000000 597 | hex 00000000 598 | 599 | s_UnderLine hex 00000000 600 | hex 00000000 601 | hex 00000000 602 | hex 00000000 603 | hex 00000000 604 | hex FFFFFFF0 605 | 606 | s_Template hex 00000000 607 | hex 00000000 608 | hex 00000000 609 | hex 00000000 610 | hex 00000000 611 | hex 00000000 612 | 613 | -------------------------------------------------------------------------------- /source/gslib.mac.s: -------------------------------------------------------------------------------- 1 | * GSLIB APP HELPER MACROS 2 | 3 | 4 | * NOISETRACKER MACROS 5 | 6 | _NTStartUp MAC 7 | LDX #$02DC 8 | JSL $E10000 9 | <<< 10 | 11 | *_NTInitMusic MAC 12 | * <<< 13 | 14 | _NTLaunchMusic MAC 15 | LDX #$0ADC 16 | JSL $E10000 17 | <<< 18 | 19 | *_NTStartMusic MAC 20 | * <<< 21 | 22 | _NTStopMusic MAC 23 | LDX #$0CDC 24 | JSL $E10000 25 | <<< 26 | 27 | _NTShutDown MAC 28 | LDX #$03DC 29 | JSL $E10000 30 | <<< 31 | 32 | 33 | -------------------------------------------------------------------------------- /source/p8_tools.s: -------------------------------------------------------------------------------- 1 | org $2000 ; start at $2000 (all ProDOS8 system files) 2 | mx %11 3 | clc 4 | xce 5 | rep #$30 6 | 7 | jsr PrepareTools 8 | jsr P8Quit 9 | 10 | ****************************************** 11 | * Call this at the start of your program * 12 | ****************************************** 13 | mx %00 14 | PrepareTools stz MasterId ; I haven't created a new user ID 15 | _TLStartUp 16 | pha 17 | _MMStartUp 18 | pla 19 | bcc MM_OK 20 | * If the Memory Manager reported an error, we need to allocate our own memory first. 21 | _MTStartUp 22 | * First we need a user ID. 23 | pha 24 | pea $1000 25 | _GetMasterId ; Get me a new user ID (Application) 26 | pla 27 | sta MasterId ; Save it for later 28 | * Now give us all of bank zero and bank one. 29 | pha 30 | pha ; Result space 31 | pea $0000 32 | pea $B800 ; Block size 33 | lda MasterId 34 | pha ; User ID 35 | pea $C002 ; Attributes: locked, fixed, absolute 36 | pea $0000 37 | pea $0800 ; Location (bank 0, $0800-$BFFF) 38 | _NewHandle 39 | plx 40 | ply 41 | _Err ; This shouldn't happen! 42 | sty Bnk0Hnd 43 | stx Bnk0Hnd+2 ; Save handle to bank 0 memory 44 | pha 45 | pha ; Result space 46 | pea $0000 47 | pea $B800 ; Block size 48 | lda MasterId 49 | pha ; User ID 50 | pea $C002 ; Attributes: locked, fixed, absolute 51 | pea $0001 52 | pea $0800 ; Location (bank 1, $0800-$BFFF) 53 | _NewHandle 54 | plx 55 | ply 56 | _Err ; This shouldn't happen! 57 | sty Bnk1Hnd 58 | stx Bnk1Hnd+2 ; Save handle to bank 0 memory 59 | * We have the necessary memory protected. Start up the memory manager again. 60 | pha 61 | _MMStartUp 62 | pla 63 | _Err ; This shouldn't happen! 64 | MM_OK sta UserId ; Save the memory ID 65 | rts 66 | 67 | ****************************************** 68 | * Basic Error Macro * 69 | ****************************************** 70 | _Err mac 71 | bcc NoErr 72 | do ]0 ; (DO if true) 73 | jsr PgmDeath ; this is conditionally compiled if 74 | str ]1 ; we pass in an error statement 75 | else ; (ELSE) 76 | jmp PgmDeath0 ; we just call the simpler error handler 77 | fin ; (FIN) 78 | NoErr eom 79 | 80 | **************************************** 81 | * Fatal Error Handler * 82 | **************************************** 83 | PgmDeath tax 84 | pla 85 | inc 86 | phx 87 | phk 88 | pha 89 | bra ContDeath 90 | PgmDeath0 pha 91 | pea $0000 92 | pea $0000 93 | ContDeath ldx #$1503 94 | jsl $E10000 95 | 96 | 97 | ****************************************** 98 | * Standard ProDOS 8 Quit routine * 99 | ****************************************** 100 | mx %11 101 | P8Quit jsr MLI ; first actual command, call ProDOS vector 102 | dfb $65 ; with "quit" request ($65) 103 | da QuitParm 104 | bcs Error ; what's the point? ;) 105 | Error brk $00 ; shouldn't ever here! 106 | 107 | QuitParm dfb 4 ; number of parameters 108 | dfb 0 ; standard quit type 109 | da $0000 ; not needed when using standard quit 110 | dfb 0 ; not used 111 | da $0000 ; not used 112 | 113 | ****************************************** 114 | * ToolCall Macros * 115 | ****************************************** 116 | Tool MAC 117 | LDX #]1 118 | JSL $E10000 119 | <<< 120 | _TLStartUp MAC 121 | Tool $201 122 | <<< 123 | _TLShutDown MAC 124 | Tool $301 125 | <<< 126 | _NewHandle MAC 127 | Tool $902 128 | <<< 129 | _MMStartUp MAC 130 | Tool $202 131 | <<< 132 | _GetMasterId MAC 133 | Tool $2003 134 | <<< 135 | _MTStartUp MAC 136 | Tool $203 137 | <<< 138 | 139 | MasterId ds 2 140 | UserId ds 2 141 | BankLoad hex 0000 ; used for Load/Unpack 142 | Bnk0Hnd hex 00000000 143 | Bnk1Hnd hex 00000000 144 | MLI equ $bf00 145 | 146 | dsk p8_tools.system 147 | -------------------------------------------------------------------------------- /source/quit.s: -------------------------------------------------------------------------------- 1 | **************************************** 2 | * Quit * 3 | * * 4 | * Dagen Brock * 5 | * 2013-06-24 * 6 | **************************************** 7 | 8 | rts ; return from wherever we were called 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /source/quit16.s: -------------------------------------------------------------------------------- 1 | **************************************** 2 | * Quit16 * 3 | * * 4 | * Dagen Brock * 5 | * 2013-06-10 * 6 | **************************************** 7 | 8 | rel ; compile as relocatable code 9 | dsk Quit.Sys16 ; Save Name 10 | typ $B3 ; S16, GS/OS Application 11 | 12 | phk ; Set Data Bank to Program Bank 13 | plb ; Always do this first! 14 | 15 | jsl $E100A8 ; Prodos 16 entry point 16 | da $29 ; Quit code 17 | adrl QuitParm ; address of parameter table 18 | bcs Error ; never taken 19 | 20 | Error brk ; should never get here 21 | 22 | QuitParm adrl $0000 ; pointer to pathname (not used here) 23 | da $00 ; quit type (absolute quit) 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /source/quit8.s: -------------------------------------------------------------------------------- 1 | **************************************** 2 | * Quit8 * 3 | * * 4 | * Dagen Brock * 5 | * 2013-06-24 * 6 | **************************************** 7 | 8 | org $2000 ; start at $2000 (all ProDOS8 system files) 9 | dsk quit8.system ; tell compiler what name for output file 10 | typ $ff ; set P8 type ($ff = "SYS") for output file 11 | 12 | MLI equ $bf00 13 | 14 | 15 | 16 | Quit jsr MLI ; first actual command, call ProDOS vector 17 | dfb $65 ; with "quit" request ($65) 18 | da QuitParm 19 | bcs Error 20 | brk $00 ; shouldn't ever here! 21 | 22 | QuitParm dfb 4 ; number of parameters 23 | dfb 0 ; standard quit type 24 | da $0000 ; not needed when using standard quit 25 | dfb 0 ; not used 26 | da $0000 ; not used 27 | 28 | 29 | Error brk $00 ; shouldn't be here either 30 | -------------------------------------------------------------------------------- /source/shr1.s: -------------------------------------------------------------------------------- 1 | **************************************** 2 | * SHR1 * 3 | * * 4 | * Dagen Brock * 5 | * 2013-07-17 * 6 | **************************************** 7 | 8 | rel ; Compile 9 | dsk SHR1.Sys16 ; Save Name 10 | typ $B3 ; S16, GS/OS Application 11 | mx %00 ; Program starts in 16-bit mode 12 | 13 | phk ; Set Data Bank to Program Bank 14 | plb ; Always do this first! 15 | 16 | GraphicsOn sep #$30 ; 8-bit mode 17 | lda #$81 18 | stal $00C029 ; Turn on SHR mode 19 | rep #$30 ; back to 16-bit mode 20 | 21 | jsr WaitKey ; pause 22 | 23 | 24 | 25 | ClearNaive ldx #$0000 ; Start at first pixel 26 | lda #$0000 ; store zeros 27 | :clearloop stal $E12000,x ; screen location 28 | inx 29 | inx 30 | cpx #$8000 ; see if we've filled entire frame/colors/scbs 31 | bne :clearloop ; pause 32 | 33 | 34 | jsr WaitKey 35 | 36 | 37 | ClearFaster ldx #$7FFE ; start at top this time 38 | lda #$0000 ; store zeros 39 | :clearloop stal $E12000,x ; screen location 40 | dex 41 | dex 42 | ; avoid 16K "compare X's" for 80K cycle savings 43 | bne :clearloop ; loop until we've worked our way down to 0 44 | jsr WaitKey 45 | 46 | 47 | jsl $E100A8 ; Prodos 16 entry point 48 | da $29 ; Quit code 49 | adrl QuitParm ; address of parameter table 50 | bcs Error ; never taken 51 | 52 | Error brk ; should never get here 53 | 54 | QuitParm adrl $0000 ; pointer to pathname (not used here) 55 | da $00 ; quit type (absolute quite) 56 | 57 | WaitKey sep #$30 ; good old apple ii key wait routine 58 | :wait ldal $00C000 ; but called using long addressing modes 59 | bpl :wait ; in 8-bit mode 60 | stal $00C010 61 | rep #$30 62 | rts 63 | 64 | 65 | -------------------------------------------------------------------------------- /source/shr2.s: -------------------------------------------------------------------------------- 1 | **************************************** 2 | * SHR2 * 3 | * * 4 | * Dagen Brock * 5 | * 2013-07-17 * 6 | **************************************** 7 | 8 | rel ;Compile 9 | dsk SHR2.Sys16 ;Save Name 10 | typ $B3 ; S16, GS/OS Application 11 | 12 | mx %00 ;Program starts in 16-bit mode 13 | 14 | phk ;Set Data Bank to Program Bank 15 | plb ;Always do this first! 16 | 17 | lda #$0FFF ; WHITE color 18 | ldx #$0001 ; palette index 1 (NOT zero) 19 | jsr SetPaletteColor 20 | 21 | lda #$0000 22 | jsr SetSCBs ;set all SCBs to 00 (320 mode, pal 0, no fill, no interrupt) 23 | jsr ClearToColor ;clear screen (fill with zeros) 24 | jsr GraphicsOn ;turn on SHR 25 | jsr WaitKey 26 | 27 | lda #$1111 ;clear screen to color 1 28 | jsr ClearToColor 29 | jsr WaitKey 30 | 31 | jsl $E100A8 ;Prodos 16 entry point 32 | da $29 ;Quit code 33 | adrl QuitParm ;address of parameter table 34 | bcs Error ;never taken 35 | 36 | Error brk ;should never get here 37 | 38 | QuitParm adrl $0000 ;pointer to pathname (not used here) 39 | da $00 ;quit type (absolute quite) 40 | 41 | 42 | **************************************** 43 | * Turn on SHR mode * 44 | **************************************** 45 | GraphicsOn sep #$30 ;8-bit mode 46 | lda #$81 ;%1000 0001 47 | stal $00C029 ;Turn on SHR mode 48 | rep #$30 ;back to 16-bit mode 49 | rts 50 | 51 | **************************************** 52 | * A= color values (0RGB) * 53 | * X= color/palette offset * 54 | * (0-F = pal0, 10-1F = pal1, etc.) * 55 | **************************************** 56 | SetPaletteColor pha ;save accumulator 57 | txa 58 | asl ;X*2 = real offset to color table 59 | tax 60 | pla 61 | stal $E19E00,x ;palettes are stored from $E19E00-FF 62 | rts ;yup, that's it 63 | 64 | **************************************** 65 | * A= color values (0RGB) * 66 | **************************************** 67 | ClearToColor ldx #$7D00 ;start at top of pixel data! ($2000-9D00) 68 | :clearloop dex 69 | dex 70 | stal $E12000,x ;screen location 71 | bne :clearloop ;loop until we've worked our way down to 0 72 | rts 73 | 74 | SetSCBs ldx #$0100 ;set all $100 scbs to A 75 | :scbloop dex 76 | dex 77 | stal $E19D00,x 78 | bne :scbloop 79 | rts 80 | 81 | WaitKey sep #$30 82 | :wait ldal $00C000 83 | bpl :wait 84 | stal $00C010 85 | rep #$30 86 | rts 87 | 88 | 89 | -------------------------------------------------------------------------------- /source/shrhello.s: -------------------------------------------------------------------------------- 1 | **************************************** 2 | * SHRHELLO * 3 | * * 4 | * Dagen Brock * 5 | * 2013-07-21 * 6 | **************************************** 7 | 8 | rel ; Compile 9 | dsk SHRHello.Sys16 ; Save Name 10 | typ $B3 ; S16, GS/OS Application 11 | mx %00 12 | phk ; Set Data Bank to Program Bank 13 | plb ; Always do this first! 14 | 15 | lda #$0FFF ; WHITE color 16 | ldx #$000F ; palette index 1 (NOT zero) 17 | jsr SetPaletteColor 18 | lda #$0589 ; other color 19 | ldx #$0001 ; palette index 1 (NOT zero) 20 | jsr SetPaletteColor 21 | lda #$0000 22 | jsr SetSCBs ; set all SCBs to 00 (320 mode, pal 0, no fill, no interrupt) 23 | jsr GraphicsOn 24 | 25 | 26 | lda #$0000 ; clear screen to color 0 and turn on SHR graphics 27 | jsr ClearToColor 28 | lda #HelloStr 29 | ldx #60*160+30 30 | jsr DrawString 31 | jsr WaitKey 32 | 33 | lda #$1111 ; clear screen to color 1 34 | jsr ClearToColor 35 | lda #HelloStr 36 | ldx #60*160+30 37 | jsr DrawString 38 | jsr WaitKey 39 | 40 | 41 | 42 | jsl $E100A8 ; Prodos 16 entry point 43 | da $29 ; Quit code 44 | adrl QuitParm ; address of parameter table 45 | bcs Error ; never taken 46 | 47 | Error brk ; should never get here 48 | 49 | QuitParm adrl $0000 ; pointer to pathname (not used here) 50 | da $00 ; quit type (absolute quite) 51 | 52 | HelloStr str 'HELLO KANSASFEST' 53 | 54 | **************************************** 55 | * Turn on SHR mode * 56 | **************************************** 57 | GraphicsOn sep #$30 ;8-bit mode 58 | lda #$81 ;%1000 0001 59 | stal $00C029 ;Turn on SHR mode 60 | rep #$30 ;back to 16-bit mode 61 | rts 62 | 63 | **************************************** 64 | * A= color values (0RGB) * 65 | * X= color/palette offset * 66 | * (0-F = pal0, 10-1F = pal1, etc.) * 67 | **************************************** 68 | SetPaletteColor pha ;save accumulator 69 | txa 70 | asl ;X*2 = real offset to color table 71 | tax 72 | pla 73 | stal $E19E00,x ;palettes are stored from $E19E00-FF 74 | rts ;yup, that's it 75 | 76 | **************************************** 77 | * A= color values (0RGB) * 78 | **************************************** 79 | ClearToColor ldx #$7D00 ;start at top of pixel data! ($2000-9D00) 80 | :clearloop dex 81 | dex 82 | stal $E12000,x ;screen location 83 | bne :clearloop ;loop until we've worked our way down to 0 84 | rts 85 | 86 | SetSCBs ldx #$0100 ;set all $100 scbs to A 87 | :scbloop dex 88 | dex 89 | stal $E19D00,x 90 | bne :scbloop 91 | rts 92 | 93 | WaitKey sep #$30 94 | :wait ldal $00c000 95 | bpl :wait 96 | stal $00c010 97 | rep #$30 98 | rts 99 | 100 | use FONT ;include our font library 101 | -------------------------------------------------------------------------------- /source/shrloadimg.m.s: -------------------------------------------------------------------------------- 1 | _TLStartUp MAC 2 | Tool $201 3 | <<< 4 | _MMStartUp MAC 5 | Tool $202 6 | <<< 7 | _NewHandle MAC 8 | Tool $902 9 | <<< 10 | _UnPackBytes MAC 11 | Tool $2703 12 | <<< 13 | _TLTextMountVol MAC 14 | Tool $1201 15 | <<< 16 | PushLong MAC 17 | IF #=]1 18 | PushWord #^]1 19 | ELSE 20 | PushWord ]1+2 21 | FIN 22 | PushWord ]1 23 | <<< 24 | PushWord MAC 25 | IF #=]1 26 | PEA ]1 27 | ELSE 28 | IF MX/2 29 | LDA ]1+1 30 | PHA 31 | FIN 32 | LDA ]1 33 | PHA 34 | FIN 35 | <<< 36 | Tool MAC 37 | LDX #]1 38 | JSL $E10000 39 | <<< 40 | -------------------------------------------------------------------------------- /source/shrloadimg.s: -------------------------------------------------------------------------------- 1 | **************************************** 2 | * SHRLOADIMG * 3 | * * 4 | * Dagen Brock * 5 | * 2013-07-21 * 6 | **************************************** 7 | 8 | rel ; Compile 9 | dsk SHRLoadImg.S16 ; Save Name 10 | typ $B3 ; S16, GS/OS Application 11 | use shrloadimg.m ; include macros from another 12 | mx %00 ; Program starts in 16-bit mode 13 | 14 | **************************************** 15 | * Basic Error Macro * 16 | **************************************** 17 | _Err mac 18 | bcc NoErr 19 | do ]0 ; (DO if true) 20 | jsr PgmDeath ; this is conditionally compiled if 21 | str ]1 ; we pass in an error statement 22 | else ; (ELSE) 23 | jmp PgmDeath0 ; we just call the simpler error handler 24 | fin ; (FIN) 25 | NoErr eom 26 | 27 | 28 | **************************************** 29 | * Program Start * 30 | **************************************** 31 | phk ; Set Data Bank to Program Bank 32 | plb ; Always do this first! 33 | 34 | 35 | **************************************** 36 | * Typical tool startup * 37 | **************************************** 38 | _TLStartUp ; normal tool initialization 39 | pha 40 | _MMStartUp 41 | _Err ; should never happen 42 | pla 43 | sta MasterId ; our master handle references the memory allocated to us 44 | ora #$0100 ; set auxID = $01 (valid values $01-0f) 45 | sta UserId ; any memory we request must use our own id 46 | 47 | **************************************** 48 | * Initialize graphics * 49 | **************************************** 50 | jsr AllocOneBank ; Alloc 64KB for Load/Unpack 51 | sta BankLoad ; Store "Bank Pointer" 52 | 53 | ldx #ImageName ; Load+Unpack Boot Picture 54 | jsr LoadPicture ; X=Name, A=Bank to use for loading 55 | 56 | lda BankLoad ; get address of loaded/uncompressed picture 57 | clc 58 | adc #$0080 ; skip header? 59 | sta :copySHR+2 ; and store that over the 'ldal' address below 60 | ldx #$7FFE ; copy all image data 61 | :copySHR ldal $000000,x ; load from BankLoad we allocated 62 | stal $E12000,x ; store to SHR screen 63 | dex 64 | dex 65 | bpl :copySHR 66 | 67 | jsr GraphicsOn 68 | 69 | jsr WaitKey 70 | 71 | bra Quit 72 | 73 | ImageName strl '1/KFEST2013.PAK' 74 | MasterId ds 2 75 | UserId ds 2 76 | BankLoad hex 0000 ; used for Load/Unpack 77 | 78 | Quit jsl $E100A8 ; Prodos 16 entry point 79 | da $29 ; Quit code 80 | adrl QuitParm ; address of parameter table 81 | bcs Error ; never taken 82 | 83 | Error brk ; should never get here 84 | 85 | QuitParm adrl $0000 ; pointer to pathname (not used here) 86 | da $00 ; quit type (absolute quite) 87 | 88 | **************************************** 89 | * AllocOneBank * 90 | * This is a custom allocation function * 91 | * that makes use of the fact that we * 92 | * request an entire locked bank and so * 93 | * simply returns the bank in the * 94 | * accumulator. (basically dereference * 95 | * the Handle to get the pointer) * 96 | **************************************** 97 | AllocOneBank PushLong #0 98 | PushLong #$10000 99 | PushWord UserId 100 | PushWord #%11000000_00011100 101 | PushLong #0 102 | _NewHandle ; returns LONG Handle on stack 103 | plx ; base address of the new handle 104 | pla ; high address 00XX of the new handle (bank) 105 | xba ; swap accumulator bytes to XX00 106 | sta :bank+2 ; store as bank for next op (overwrite $XX00) 107 | :bank ldal $000001,X ; recover the bank address in A=XX/00 108 | rts 109 | 110 | **************************************** 111 | * Graphics Helpers * 112 | **************************************** 113 | LoadPicture jsr LoadFile ; X=Nom Image, A=Banc de chargement XX/00 114 | bcc :loadOK 115 | brl Exit 116 | :loadOK jsr UnpackPicture ; A=Packed Size 117 | rts 118 | 119 | 120 | UnpackPicture sta UP_PackedSize ; Size of Packed Data 121 | lda #$8000 ; Size of output Data Buffer 122 | sta UP_UnPackedSize 123 | lda BankLoad ; Banc de chargement / Decompression 124 | sta UP_Packed+1 ; Packed Data 125 | clc 126 | adc #$0080 127 | stz UP_UnPacked ; On remet a zero car modifie par l'appel 128 | stz UP_UnPacked+2 129 | sta UP_UnPacked+1 ; Unpacked Data buffer 130 | 131 | PushWord #0 ; Space for Result : Number of bytes unpacked 132 | PushLong UP_Packed ; Pointer to buffer containing the packed data 133 | PushWord UP_PackedSize ; Size of the Packed Data 134 | PushLong #UP_UnPacked ; Pointer to Pointer to unpacked buffer 135 | PushLong #UP_UnPackedSize ; Pointer to a Word containing size of unpacked data 136 | _UnPackBytes 137 | pla ; Number of byte unpacked 138 | rts 139 | 140 | UP_Packed hex 00000000 ; Address of Packed Data 141 | UP_PackedSize hex 0000 ; Size of Packed Data 142 | UP_UnPacked hex 00000000 ; Address of Unpacked Data Buffer (modified) 143 | UP_UnPackedSize hex 0000 ; Size of Unpacked Data Buffer (modified) 144 | 145 | **************************************** 146 | * Turn on SHR mode * 147 | **************************************** 148 | GraphicsOn sep #$30 ; 8-bit mode 149 | lda #$C1 150 | stal $00C029 ; Turn on SHR mode 151 | rep #$30 ; back to 16-bit mode 152 | rts 153 | 154 | WaitKey sep #$30 155 | :wait ldal $00C000 156 | bpl :wait 157 | stal $00C010 158 | rep #$30 159 | rts 160 | 161 | 162 | 163 | **************************************** 164 | * Fatal Error Handler * 165 | **************************************** 166 | PgmDeath tax 167 | pla 168 | inc 169 | phx 170 | phk 171 | pha 172 | bra ContDeath 173 | PgmDeath0 pha 174 | pea $0000 175 | pea $0000 176 | ContDeath ldx #$1503 177 | jsl $E10000 178 | 179 | 180 | **************************************** 181 | * Normal GSOS Quit * 182 | **************************************** 183 | Exit jsl GSOS 184 | dw $2029 185 | adrl QuitGS 186 | 187 | 188 | **************************************** 189 | * GS/OS / ProDOS 16 File Routines * 190 | **************************************** 191 | GSOS = $E100A8 192 | 193 | LoadFile stx OpenGS+4 ; X=File, A=Bank/Page XX/00 194 | sta ReadGS+5 195 | 196 | :openFile jsl GSOS ; Open File 197 | dw $2010 198 | adrl OpenGS 199 | bcs :openReadErr 200 | lda OpenGS+2 201 | sta GetEOFGS+2 202 | sta ReadGS+2 203 | 204 | jsl GSOS ; Get File Size 205 | dw $2019 206 | adrl GetEOFGS 207 | lda GetEOFGS+4 208 | sta ReadGS+8 209 | lda GetEOFGS+6 210 | sta ReadGS+10 211 | 212 | jsl GSOS ; Read File Content 213 | dw $2012 214 | adrl ReadGS 215 | bcs :openReadErr 216 | 217 | :closeFile jsl GSOS ; Close File 218 | dw $2014 219 | adrl CloseGS 220 | clc 221 | lda GetEOFGS+4 ; File Size 222 | rts 223 | 224 | :openReadErr jsr :closeFile 225 | nop 226 | nop 227 | 228 | PushWord #0 229 | PushLong #msgLine1 230 | PushLong #msgLine2 231 | PushLong #msgLine3 232 | PushLong #msgLine4 233 | _TLTextMountVol ; actualname is TLTextMountVolume 234 | pla 235 | cmp #1 236 | bne :loadFileErr 237 | brl :openFile 238 | :loadFileErr sec 239 | rts 240 | 241 | msgLine1 str 'Unable to load File' 242 | msgLine2 str 'Press a key :' 243 | msgLine3 str ' -> Return to Try Again' 244 | msgLine4 str ' -> Esc to Quit' 245 | 246 | 247 | OpenGS dw 2 ; pCount 248 | ds 2 ; refNum 249 | adrl ImageName ; pathname 250 | 251 | GetEOFGS dw 2 ; pCount 252 | ds 2 ; refNum 253 | ds 4 ; eof 254 | 255 | ReadGS dw 4 ; pCount 256 | ds 2 ; refNum 257 | ds 4 ; dataBuffer 258 | ds 4 ; requestCount 259 | ds 4 ; transferCount 260 | 261 | CloseGS dw 1 ; pCount 262 | ds 2 ; refNum 263 | 264 | QuitGS dw 2 ; pCount 265 | ds 4 ; pathname 266 | ds 2 ; flags 267 | 268 | -------------------------------------------------------------------------------- /source/skel.macgen.s: -------------------------------------------------------------------------------- 1 | _TLStartUp MAC 2 | Tool $201 3 | <<< 4 | _MMStartUp MAC 5 | Tool $202 6 | <<< 7 | _MMShutDown MAC 8 | Tool $302 9 | <<< 10 | _NewHandle MAC 11 | Tool $902 12 | <<< 13 | _UnPackBytes MAC 14 | Tool $2703 15 | <<< 16 | PushLong MAC 17 | IF #=]1 18 | PushWord #^]1 19 | ELSE 20 | PushWord ]1+2 21 | FIN 22 | PushWord ]1 23 | <<< 24 | PushWord MAC 25 | IF #=]1 26 | PEA ]1 27 | ELSE 28 | IF MX/2 29 | LDA ]1+1 30 | PHA 31 | FIN 32 | LDA ]1 33 | PHA 34 | FIN 35 | <<< 36 | Tool MAC 37 | LDX #]1 38 | JSL $E10000 39 | <<< 40 | -------------------------------------------------------------------------------- /source/torus.s: -------------------------------------------------------------------------------- 1 | Drawtorus ASL ; A=Sprite Number ($0000-$003C) 2 | TAX ; Y=Target Screen Address ($2000-$9D00) 3 | LDA torusNum,X ; Relative Sprite Number Table 4 | JMP (torusBank,X) ; Bank Number Table 5 | 6 | torusNum HEX 1600,1400,0E00,1300,0400,0100,0600,1200 7 | HEX 0200,0F00,0800,1800,1700,1F00,1E00,2200 8 | HEX 2700,2600,3000,2D00,3600,3500,3C00,3700 9 | HEX 3100,2F00,2800,2300,2000,1500,1000,0700 10 | HEX 0C00,0D00,0300,0000,0500,0B00,0A00,0900 11 | HEX 1100,1A00,1900,1B00,1D00,2100,2A00,2400 12 | HEX 2900,2C00,2E00,3300,3900,3B00,3800,3400 13 | HEX 3200,2B00,2500,1C00,3A00 14 | 15 | torusBank DA torusBank00,torusBank00,torusBank00,torusBank00,torusBank00,torusBank00,torusBank00,torusBank00 16 | DA torusBank00,torusBank00,torusBank00,torusBank00,torusBank00,torusBank00,torusBank00,torusBank00 17 | DA torusBank00,torusBank00,torusBank00,torusBank00,torusBank00,torusBank00,torusBank00,torusBank00 18 | DA torusBank00,torusBank00,torusBank00,torusBank00,torusBank00,torusBank00,torusBank00,torusBank00 19 | DA torusBank00,torusBank00,torusBank00,torusBank00,torusBank00,torusBank00,torusBank00,torusBank00 20 | DA torusBank00,torusBank00,torusBank00,torusBank00,torusBank00,torusBank00,torusBank00,torusBank00 21 | DA torusBank00,torusBank00,torusBank00,torusBank00,torusBank00,torusBank00,torusBank00,torusBank00 22 | DA torusBank00,torusBank00,torusBank00,torusBank00,torusBank00 23 | 24 | torusBank00 JSL $AA0000 25 | PHK 26 | PLB 27 | RTS 28 | 29 | *------------------------------------------------ 30 | --------------------------------------------------------------------------------