├── .gitignore ├── LICENSE.txt ├── Makefile ├── README.md ├── colors.bin ├── config.default.template ├── engine.acme ├── joystick.acme ├── lib ├── basic.acme ├── cia.acme ├── mem.acme ├── std.acme └── vic.acme ├── map.bin ├── pixels.bin ├── raster.acme ├── screen.bin ├── scroll.acme ├── snd ├── transylvanian.bin └── transylvanian.sng ├── spr ├── hero.raw └── hero.spd ├── tiles.acme └── toys ├── color_matrix.acme └── make_palette.py /.gitignore: -------------------------------------------------------------------------------- 1 | *.d64 2 | *.exo 3 | *.l 4 | *.prg 5 | *.tc 6 | config.default 7 | krill 8 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | {one line to give the program's name and a brief idea of what it does.} 635 | Copyright (C) {year} {name of author} 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | {project} Copyright (C) {year} {fullname} 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | CONFIG ?= config.default 2 | -include $(CONFIG) 3 | 4 | OUT ?= engine 5 | D64 ?= $(OUT).d64 6 | KRILL ?= ./krill 7 | KRILL_URL ?= "http://csdb.dk/getinternalfile.php/196649/loader-v184.zip" 8 | INC ?= $(KRILL)/loader/build/loadersymbols-c64.inc 9 | CC1541 ?= $(KRILL)/loader/tools/cc1541/cc1541 10 | EXO ?= $(KRILL)/loader/tools/exomizer-3/src/exomizer 11 | TC ?= $(KRILL)/loader/tools/tinycrunch_v1.2/tc_encode.py 12 | 13 | ENGINE_ACME := engine.acme 14 | ENGINE_OBJ := $(filter %.obj, $(ENGINE_ACME:.acme=.obj)) 15 | ENGINE_EXO := $(filter %.exo, $(ENGINE_OBJ:.obj=.exo)) 16 | 17 | ENGINE_BIN := $(wildcard *.bin) 18 | ENGINE_PRG := $(filter %.prg, $(ENGINE_BIN:.bin=.prg)) 19 | ENGINE_TC := $(filter %.tc, $(ENGINE_PRG:.prg=.tc)) 20 | 21 | map.bin.addr := '\x00\x30' 22 | colors.bin.addr := '\x00\x90' 23 | screen.bin.addr := '\x00\x96' 24 | pixels.bin.addr := '\x00\x9c' 25 | 26 | # use 'make Q=' to get a verbose output of all commands 27 | Q ?= @ 28 | 29 | all: $(D64) 30 | 31 | $(INC): 32 | @echo '===> INSTALL KRILL LOADER' 33 | $(Q)$(WGET) $(KRILL_URL) -O krill.zip 34 | $(Q)$(MKDIR) $(KRILL) 35 | $(Q)$(UNZIP) krill.zip -d $(KRILL) 36 | $(Q)$(MAKE) -C $(KRILL)/loader 37 | 38 | $(CC1541): $(INC) 39 | @echo '===> INSTALL CC1541' 40 | $(Q)$(MAKE) -C $(KRILL)/loader/tools/cc1541 41 | 42 | $(EXO): $(INC) 43 | @echo '===> INSTALL EXOMIZER' 44 | $(Q)$(MAKE) -C $(KRILL)/loader/tools/exomizer-3/src 45 | 46 | %.obj: %.acme $(INC) 47 | @echo '===> ACME $<' 48 | $(Q)$(ACME) -f cbm -DSYSTEM=64 -o $@ $< 49 | 50 | %.exo: %.obj $(EXO) 51 | @echo '===> EXO $<' 52 | $(EXO) sfx sys $< -B -x1 -o $@ 53 | 54 | %.prg: %.bin 55 | @echo '===> BIN to PRG $<' 56 | $(Q)printf $($(<).addr) | cat - $< > $@ 57 | 58 | %.tc: %.prg $(INC) 59 | @echo '===> TC $<' 60 | $(Q)$(TC) -i $< $@ 61 | 62 | $(D64): $(CC1541) $(ENGINE_TC) $(ENGINE_EXO) 63 | @echo '===> CC1541 $@' 64 | $(Q)$(CC1541) -n $(OUT) -f "$(OUT)#a0,8,1" -w $(ENGINE_EXO) -f map -w map.tc -f colors -w colors.tc -f screen -w screen.tc -f pixels -w pixels.tc $(D64) 65 | 66 | clean: 67 | @echo '===> CLEAN' 68 | $(Q)rm -f $(D64) $(ENGINE_EXO) $(ENGINE_TC) krill.zip 69 | 70 | distclean: clean 71 | @echo '===> DISTCLEAN' 72 | $(Q)rm -rf $(KRILL) 73 | 74 | run: $(D64) 75 | @echo '===> RUN $<' 76 | $(Q)$(X64) -device8 0 +iecdevice8 -drive8truedrive -8 $(D64) 77 | 78 | dev: 79 | @echo '===> DEV' 80 | rm -f engine.prg 81 | $(Q)$(ACME) -DSYSTEM=64 -DDEVELOP=1 -DDEBUG=1 engine.acme 82 | 83 | prg: 84 | @echo '===> PRG' 85 | rm -f engine.prg 86 | $(Q)$(ACME) -DSYSTEM=64 -DDEVELOP=1 engine.acme 87 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # c64engine 2 | 3 | A game engine for the c64. 4 | 5 | ## Building 6 | 7 | Dependencies: 8 | * [acme](https://sourceforge.net/projects/acme-crossass/) 9 | * [cc65](https://github.com/cc65/cc65) 10 | 11 | The following dependencies are automatically dealt with by the `Makefile`: 12 | * [Krill's loader](https://csdb.dk/release/?id=189130) 13 | * [exomizer](https://github.com/exomiser/Exomiser) (using Krill's intree sources) 14 | * [tinycrunch](https://csdb.dk/release/?id=168629) (using Krill's intree sources) 15 | 16 | ```bash 17 | cp config.default.template config.default 18 | vim config.default # edit 19 | make 20 | ``` 21 | 22 | ## Running 23 | 24 | Before running in VICE, make sure _True drive emulation_ is enabled and _IEC-device_ is **disabled**. 25 | ```bash 26 | make run 27 | ``` 28 | 29 | Use joystick in port 2 to run the demo. 30 | 31 | ## Features 32 | 33 | * Bitmap scrolling using [AGSP](http://codebase64.org/doku.php?id=base:agsp_any_given_screen_position) 34 | 35 | This technique only requires 36 raster lines CPU time and 33 raster lines of screen space. All other screen space - including screen memory (used for colors ```%01``` and ```%10```) and color ram (color ```%11```) is moved around as well. 36 | 37 | * Sprite-Multiplexer 38 | 39 | Multiplixing 24 x 2 sprites. This means 24 virtual multi-color sprites where each sprite is overlayed with a single-color sprite for more colors and better resolution. 40 | 41 | * Tile-Copying 42 | 43 | The binary format of the files is as follows: 44 | 45 | * `map.bin`: `map width` * `map height` bytes (here 256 * 96). 46 | 47 | Each byte is a tile index into the tile data: pixels, screen, colors 48 | 49 | * `pixels.bin`: `tile width` * `tile height` * 8 bytes per tile (here 3 * 2 * 8). 50 | 51 | Each bit pair in a byte is a color number: 0-3 (multicolor) 52 | 53 | * `screen.bin`: `tile width` * `tile height` bytes per tile. 54 | 55 | For each byte, the upper 4 bits are color 1 and the lower 4 bits are color 2 56 | 57 | * `colors.bin`: `tile width` * `tile height` bytes per tile. 58 | 59 | For each byte, the upper 4 bits are ignored and the lower 4 bits are color 3 60 | 61 | Color `%00` (the shared background color) is black, but this can of course be changed to any of the 16 colors. 62 | If you are generating your own tile data, it is adviced to give priority to color number `%11`. 63 | In this way it is possible to reduce the problem of the sprite pointers overwriting the screen colors if certain tiles use only color `%00` & color `%11`. 64 | 65 | * Map-loader (credits for the disk loader go to Krill) 66 | 67 | ## Useful Links 68 | 69 | * [Spritemate](http://spritemate.com/) 70 | * [Secret colours of the Commodore 64](http://www.aaronbell.com/secret-colours-of-the-commodore-64/) 71 | * [Commodore VIC-II Color Analysis](http://unusedino.de/ec64/technical/misc/vic656x/colors/) 72 | * [Commodore 64 memory map](http://sta.c64.org/cbm64mem.html) 73 | -------------------------------------------------------------------------------- /colors.bin: -------------------------------------------------------------------------------- 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 |           33 | 34 |                          35 |       36 |      37 | 38 |     39 | 40 |    41 |  42 |    43 |              44 |       45 |  -------------------------------------------------------------------------------- /config.default.template: -------------------------------------------------------------------------------- 1 | ACME := /usr/bin/acme 2 | MAKE := /usr/bin/make 3 | MKDIR := /usr/bin/mkdir 4 | UNZIP := /usr/bin/unzip 5 | WGET := /usr/bin/wget 6 | X64 := /usr/bin/x64sc 7 | -------------------------------------------------------------------------------- /engine.acme: -------------------------------------------------------------------------------- 1 | !ifdef DEVELOP { 2 | !to "engine.prg", cbm ; output program 3 | } 4 | !sl "labels.l" ; create label file for vice 5 | !convtab scr ; for conversion to c64 screen codes 6 | 7 | !source "lib/mem.acme" 8 | !source "lib/vic.acme" 9 | !source "lib/cia.acme" 10 | !source "lib/std.acme" 11 | !ifndef DEVELOP { 12 | !source "krill/loader/build/loadersymbols-c64.inc" 13 | } 14 | 15 | !ifdef DEBUG { 16 | CONTROL_X = %00011000 ; 40 cols 17 | CONTROL_Y_INVALID = %00111000 ; 25 rows 18 | } else { 19 | CONTROL_X = %00010000 ; multi color 20 | CONTROL_Y_INVALID = %01110000 ; invalid mode 21 | } 22 | 23 | CONTROL_Y_MASK = %10111111 ; bitmap mode 24 | LINE_0 = FIRST_BADLINE-3 25 | SCROLL_SPEED = 1 ; supported are 1 or 2 26 | TILE_COLS = 3 ; 40 - 1 / 3 = whole number = 13 27 | TILE_ROWS = 2 ; 23 - 1 / 2 = whole number = 11 28 | SCR_COLS = 40 ; horizontal screen chars in memory. the screen is in 38x24 mode 29 | SCR_ROWS = 25 ; vertical screen chars in memory. the screen is in 38x24 mode 30 | MAP_WIDTH = 256 ; assumed by the code, no other widths supported atm 31 | MAP_HEIGHT = 96 ; not really used in the code, but good to know nonetheless 32 | SPRITES = 24 ; 0 or at least 4 as this number includes the sprites in the crunch area 33 | SPRITES_TOP_Y = 60 ; sprite position in fld/crunch area, can be somewhere between 55 and 60 34 | SPRITES_MAX_Y = 229 ; the lower, the more off-screen raster time we have to do other things 35 | TILES = 185 ; TODO: calculate this with pixels.bin size / 8 / TILE_COLS / TILE_ROWS 36 | COPY_ROW_FRAMES = 2 ; use 2 frames to copy all rows, vertically 37 | !if SCROLL_SPEED = 2 { 38 | COPY_COL_FRAMES = 2 ; use 2 frames to copy all cols, horizontally 39 | } else { 40 | COPY_COL_FRAMES = 4 ; use 4 frames to copy all cols, horizontally 41 | } 42 | 43 | *=SPR_DATA 44 | 45 | _spr_y 46 | !by SPRITES_TOP_Y, SPRITES_TOP_Y, SPRITES_TOP_Y, SPRITES_TOP_Y 47 | !by $64, $66, $68, $6a, $84, $86, $88, $8a, $a4, $a6, $a8, $aa, $c0, $c2, $c4, $c6, $e5, $e5, $e5, $e5 48 | SPR_X 49 | !by $20, $40, $60, $80, $50, $60, $70, $80, $10, $20, $30, $40, $50, $60, $70, $80, $10, $20, $30, $40, $50, $60, $70, $80 50 | SPR_A 51 | !by $0a, $0a, $02, $03, $04, $05, $06, $07, $08, $09, $0a, $0a, $0a, $0d, $0e, $0f, $00, $01, $02, $03, $04, $05, $06, $07 52 | SPR_B 53 | !by $00, $00, $0d, $0c, $0b, $0a, $09, $08, $07, $06, $05, $00, $00, $02, $01, $00, $0f, $0e, $0d, $0c, $0b, $0a, $09, $08 54 | SPR_F 55 | !by SPR_FR_BASE+$00, SPR_FR_BASE+$02, SPR_FR_BASE+$04, SPR_FR_BASE+$06 56 | !by SPR_FR_BASE+$08, SPR_FR_BASE+$0a, SPR_FR_BASE+$0c, SPR_FR_BASE+$0e 57 | !by SPR_FR_BASE+$10, SPR_FR_BASE+$12, SPR_FR_BASE+$14, SPR_FR_BASE+$00 58 | !by SPR_FR_BASE+$02, SPR_FR_BASE+$1a, SPR_FR_BASE+$1c, SPR_FR_BASE+$1e 59 | !by SPR_FR_BASE+$04, SPR_FR_BASE+$04, SPR_FR_BASE+$04, SPR_FR_BASE+$06 60 | !by SPR_FR_BASE+$08, SPR_FR_BASE+$0a, SPR_FR_BASE+$0c, SPR_FR_BASE+$0e 61 | 62 | +create_basic_starter CODE_START 63 | *=CODE_START 64 | 65 | !zone { 66 | ;------------------------------------------------------------------------------- 67 | ; install 1541 code (credits for the disk loader go to Krill) 68 | ;------------------------------------------------------------------------------- 69 | 70 | !ifndef DEVELOP { 71 | jsr install 72 | bcc + 73 | ldx #0 74 | - 75 | sta $d020 76 | stx $d020 77 | jmp - 78 | + 79 | } 80 | 81 | ;------------------------------------------------------------------------------- 82 | ; disable all basic, kernal and irq crap 83 | ;------------------------------------------------------------------------------- 84 | 85 | ; set empty interrupt routine 86 | +set16 EMPTY_INTERRUPT, VECTOR_NMI 87 | +set16 EMPTY_INTERRUPT, VECTOR_IRQ 88 | 89 | ; disable IRQs 90 | sei 91 | 92 | ; disable ROMs 93 | +set ALL_RAM_WITH_IO, RAM_ROM_SELECTION 94 | +disable_timer_interrupts 95 | 96 | lda #0 97 | ; no IRQs 98 | sta VIC_IRQ_CONTROL 99 | ; set timer A to 0 100 | sta CIA2_TIMER_A_LO 101 | sta CIA2_TIMER_A_HI 102 | 103 | ; trigger timer A interrupt 104 | +set %10000001, CIA2_INTERRUPT_CONTROL 105 | +set %00000001, CIA2_CONTROL_TIMER_A 106 | 107 | ; reset stack 108 | ldx #$ff 109 | txs 110 | 111 | ; just clear this flag and never ever touch this again 112 | cld 113 | 114 | ; -> NMI is disabled as soon as EMPTY_INTERRUPT has been triggered since we will never ever ack NMI again 115 | ; -> zero page completely free on this spot except for the special regs $00 and $01 116 | 117 | ;------------------------------------------------------------------------------- 118 | ; copy loader code to work area $0200 ~ $0400 119 | ;------------------------------------------------------------------------------- 120 | 121 | !ifndef DEVELOP { 122 | ; copy 2 pages 123 | ldy #2 124 | ldx #0 125 | .copy_loop 126 | lda DISK_LOADER_SRC, x 127 | sta DISK_LOADER, x 128 | dex 129 | bne .copy_loop 130 | inc .copy_loop + 2 131 | inc .copy_loop + 5 132 | dey 133 | bne .copy_loop 134 | } 135 | 136 | ;------------------------------------------------------------------------------- 137 | ; setup VIC 138 | ;------------------------------------------------------------------------------- 139 | 140 | ; select VIC area: bank 3 141 | lda #0; upper 6 bits must always be 0 142 | sta CIA2_DATA_PORT_A 143 | 144 | ; select screen bank 8, hires-bank 0 145 | lda #%10000000 146 | sta VIC_ADDR_SELECT 147 | 148 | +set %10101010, VIC_SPR_MULTI 149 | +set BROWN, VIC_SPR_COLOR_01 150 | +set GREY, VIC_SPR_COLOR_11 151 | +set $ff, VIC_SPR_ENABLE 152 | 153 | ;------------------------------------------------------------------------------- 154 | ; setup test stuff 155 | ;------------------------------------------------------------------------------- 156 | 157 | !if SPRITES > 0 { 158 | !for .i, 0, SPRITES-1 { 159 | lda _spr_y + .i 160 | sta SPR_Y + .i 161 | lda #.i 162 | sta SPR_I + .i 163 | } 164 | } 165 | 166 | !if SPRITES < 4 { 167 | ldx #$ff-(2^(8-(2*SPRITES))-1) 168 | } else { 169 | ldx #$ff 170 | } 171 | stx VIC_SPR_ENABLE 172 | 173 | ;---can be done at compile time?--- 174 | ldx #CONTROL_Y_INVALID 175 | stx CTRL_Y_INVALID 176 | 177 | ldx #0 178 | stx C_COPY 179 | stx R_COPY 180 | stx SCROLL_U_D 181 | stx SCROLL_L_R 182 | 183 | ldx #COLOR_BLACK 184 | stx VIC_BACKGROUND_0 185 | stx VIC_BORDER 186 | 187 | ldx #2 188 | stx TILE_COL 189 | ldx #1 190 | stx TILE_ROW 191 | 192 | ; ldx #TILE_MAP 198 | ; ldx #$40 199 | ldx #$22 200 | stx C_MAP_POS_HI 201 | stx R_MAP_POS_HI 202 | 203 | ldx #0 204 | stx C_SCR_POS_LO 205 | stx C_SCR_POS_HI 206 | stx R_SCR_POS_LO 207 | stx R_SCR_POS_HI 208 | stx C_PIX_POS_LO 209 | stx C_PIX_POS_HI 210 | stx R_PIX_POS_LO 211 | stx R_PIX_POS_HI 212 | ;---------------------------------- 213 | 214 | ;------------------------------------------------------------------------------- 215 | ; setup sound 216 | ;------------------------------------------------------------------------------- 217 | 218 | lda #0 ; starting from 0 219 | jsr INIT_SONG 220 | 221 | ;------------------------------------------------------------------------------- 222 | ; load map data and initialize screen 223 | ;------------------------------------------------------------------------------- 224 | 225 | !ifndef DEVELOP { 226 | jmp .load 227 | 228 | .load_error 229 | ldx #0 230 | - 231 | sta $d020 232 | stx $d020 233 | jmp - 234 | 235 | !convtab pet { 236 | tile_map 237 | !tx "map" 238 | !by 0 239 | tile_clr 240 | !tx "colors" 241 | !by 0 242 | tile_scr 243 | !tx "screen" 244 | !by 0 245 | tile_pix 246 | !tx "pixels" 247 | !by 0 248 | } 249 | 250 | .load 251 | ldx #tile_map 253 | jsr loadcompd 254 | bcs .load_error 255 | 256 | ldx #tile_clr 258 | jsr loadcompd 259 | bcs .load_error 260 | 261 | ldx #tile_scr 263 | jsr loadcompd 264 | bcs .load_error 265 | 266 | ldx #tile_pix 268 | jsr loadcompd 269 | bcs .load_error 270 | } 271 | 272 | jsr init_screen 273 | 274 | ;------------------------------------------------------------------------------- 275 | ; setup raster irq 276 | ;------------------------------------------------------------------------------- 277 | 278 | ; ack all interrupts which might have happend 279 | +set $ff, VIC_IRQ_STATUS 280 | 281 | +set16 IRQ, VECTOR_IRQ 282 | +set_raster_line_9 LINE_0 283 | +set 1, VIC_IRQ_CONTROL 284 | ; enable IRQs 285 | cli 286 | - 287 | ; some 7 cycle garbage instructions 288 | lda ($f0), y 289 | lda ($f0, x) 290 | lda ($f0), y 291 | lda ($f0, x) 292 | lda ($f0), y 293 | sec ; 2 294 | +bcs ; 3 295 | jmp - 296 | } 297 | 298 | !source "scroll.acme" 299 | !source "joystick.acme" 300 | !source "raster.acme" 301 | !source "tiles.acme" 302 | 303 | init_screen !zone { 304 | lda #(8*SCR_COLS/SCROLL_SPEED % 256) 305 | sta INIT_SCREEN_LO 306 | lda #1+(8*SCR_COLS/SCROLL_SPEED / 256) 307 | sta INIT_SCREEN_HI 308 | - 309 | jsr SCROLL_L 310 | jsr COPY_TILES 311 | dec INIT_SCREEN_LO 312 | bne - 313 | lda #$ff 314 | sta INIT_SCREEN_LO 315 | dec INIT_SCREEN_HI 316 | bne - 317 | 318 | rts 319 | } 320 | 321 | !ifdef DEBUG { 322 | !warn "code ends on: ", *-1 323 | } 324 | 325 | *=SONG_DATA 326 | !bin "snd/transylvanian.bin" 327 | 328 | !ifndef DEVELOP { 329 | *=DISK_LOADER_SRC 330 | !bin "krill/loader/build/loader-c64.prg",,2 331 | 332 | *=DISK_INSTALLER 333 | !bin "krill/loader/build/install-c64.prg",,2 334 | } 335 | 336 | !ifdef DEVELOP { 337 | *=TILE_MAP 338 | !bin "map.bin" 339 | 340 | *=TILE_CLR 341 | !bin "colors.bin" 342 | 343 | *=TILE_SCR 344 | !bin "screen.bin" 345 | 346 | *=TILE_PIX 347 | !bin "pixels.bin" 348 | } 349 | 350 | *=SPR_FR 351 | !bin "spr/hero.raw", 64*4 352 | 353 | !for .i, 0, 15 { 354 | +sprite_line %.............#.#.#.#.#.# 355 | +sprite_line %.............#.#.#.#.#.# 356 | +sprite_line %.............#.#.#.#.#.# 357 | +sprite_line %.............#.#.#.#.#.# 358 | +sprite_line %.............#.#.#.#.#.# 359 | +sprite_line %.............#.#.#.#.#.# 360 | +sprite_line %.............#.#.#.#.#.# 361 | +sprite_line %.............#.#.#.#.#.# 362 | +sprite_line %.............#.#.#.#.#.# 363 | ;+sprite_line %.............#.#.#.#.#.# 364 | !by .i, .i, .i 365 | !by .i, .i, .i 366 | !by .i, .i, .i 367 | ;+sprite_line %#.#.#.#.#.#.############ 368 | +sprite_line %#.#.#.#.#.#.############ 369 | +sprite_line %#.#.#.#.#.#.############ 370 | +sprite_line %#.#.#.#.#.#.############ 371 | +sprite_line %#.#.#.#.#.#.############ 372 | +sprite_line %#.#.#.#.#.#.############ 373 | +sprite_line %#.#.#.#.#.#.############ 374 | +sprite_line %#.#.#.#.#.#.############ 375 | +sprite_line %#.#.#.#.#.#.############ 376 | +sprite_line %#.#.#.#.#.#.############ 377 | !by $00; padding 378 | +sprite_line %######################## 379 | +sprite_line %#.#..................#.# 380 | +sprite_line %#..#................#..# 381 | +sprite_line %#...#..............#...# 382 | +sprite_line %#....#............#....# 383 | +sprite_line %#.....#..........#.....# 384 | +sprite_line %#......#........#......# 385 | +sprite_line %#.......#......#.......# 386 | +sprite_line %#........#....#........# 387 | +sprite_line %#.........#..#.........# 388 | +sprite_line %#..........##..........# 389 | +sprite_line %#.........#..#.........# 390 | +sprite_line %#........#....#........# 391 | +sprite_line %#.......#......#.......# 392 | +sprite_line %#......#........#......# 393 | +sprite_line %#.....#..........#.....# 394 | +sprite_line %#....#............#....# 395 | +sprite_line %#...#..............#...# 396 | +sprite_line %#..#................#..# 397 | +sprite_line %#.#..................#.# 398 | +sprite_line %######################## 399 | !by $00; padding 400 | } 401 | 402 | !ifdef DEBUG { 403 | !warn "frames end on: ", *-1 404 | } 405 | -------------------------------------------------------------------------------- /joystick.acme: -------------------------------------------------------------------------------- 1 | JOYSTICK !zone { 2 | ldx CUR_SPR 3 | inc SPR_A, x 4 | 5 | lda CIA1_PORT_2 6 | asl 7 | asl 8 | asl 9 | 10 | .fire 11 | asl 12 | pha 13 | bcs .right 14 | dec CUR_SPR 15 | bpl .right 16 | lda #SPRITES-1 17 | sta CUR_SPR 18 | 19 | .right 20 | pla 21 | asl 22 | bcs .left 23 | 24 | pha 25 | jsr SCROLL_R 26 | pla 27 | 28 | ldx CUR_SPR 29 | inc SPR_X, x 30 | 31 | .left 32 | asl 33 | bcs .down 34 | 35 | pha 36 | jsr SCROLL_L 37 | pla 38 | 39 | ldx CUR_SPR 40 | dec SPR_X, x 41 | 42 | .down 43 | asl 44 | bcs .up 45 | 46 | pha 47 | jsr SCROLL_D 48 | pla 49 | 50 | ldx CUR_SPR 51 | ldy SPR_Y, x 52 | cpy #SPRITES_MAX_Y 53 | beq .up 54 | cpy #SPRITES_TOP_Y 55 | beq .up 56 | inc SPR_Y, x 57 | 58 | .up 59 | asl 60 | bcs .exit 61 | 62 | jsr SCROLL_U 63 | 64 | ldx CUR_SPR 65 | ldy SPR_Y, x 66 | cpy #FIRST_BADLINE+SCR_ROWS 67 | beq .exit 68 | cpy #SPRITES_TOP_Y 69 | beq .exit 70 | dec SPR_Y, x 71 | 72 | .exit 73 | rts 74 | } 75 | 76 | CUR_SPR 77 | !by SPRITES-1 78 | -------------------------------------------------------------------------------- /lib/basic.acme: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/leissa/c64engine/7a6d3b692173578919ff37b35eab76d7f570e5f8/lib/basic.acme -------------------------------------------------------------------------------- /lib/cia.acme: -------------------------------------------------------------------------------- 1 | ; CIA1 and CIA2 constants 2 | 3 | CIA1 = $DC00 4 | CIA2 = $DD00 5 | 6 | CIA1_PORT_2 = $DC00 7 | CIA1_PORT_1 = $DC01 8 | CIA1_TIMER_A_LO = $DC04 9 | CIA1_TIMER_A_HI = $DC05 10 | CIA1_TIMER_B_LO = $DC06 11 | CIA1_TIMER_B_HI = $DC07 12 | CIA1_INTERRUPT_CONTROL = $DC0D 13 | 14 | ;Bit 0..1: Select the position of the VIC-memory 15 | ; * %00, 0: Bank 3: $C000-$FFFF, 49152-65535 16 | ; * %01, 1: Bank 2: $8000-$BFFF, 32768-49151 17 | ; * %10, 2: Bank 1: $4000-$7FFF, 16384-32767 18 | ; * %11, 3: Bank 0: $0000-$3FFF, 0-16383 (standard) 19 | ;Bit 2: RS-232: TXD Output, Userport: Data PA 2 (pin M) 20 | ;Bit 3..5: serial bus Output (0=High/Inactive, 1=Low/Active) 21 | ; * Bit 3: ATN OUT 22 | ; * Bit 4: CLOCK OUT 23 | ; * Bit 5: DATA OUT 24 | ;Bit 6..7: serial bus Input (0=Low/Active, 1=High/Inactive) 25 | ; * Bit 6: CLOCK IN 26 | ; * Bit 7: DATA IN 27 | CIA2_DATA_PORT_A = $DD00 28 | 29 | CIA2_TIMER_A_LO = $DD04 30 | CIA2_TIMER_A_HI = $DD05 31 | CIA2_TIMER_B_LO = $DD06 32 | CIA2_TIMER_B_HI = $DD07 33 | CIA2_INTERRUPT_CONTROL = $DD0D 34 | CIA2_CONTROL_TIMER_A = $DD0E 35 | 36 | !macro disable_timer_interrupts { 37 | lda #%01111111 38 | sta CIA1_INTERRUPT_CONTROL 39 | sta CIA2_INTERRUPT_CONTROL 40 | } 41 | -------------------------------------------------------------------------------- /lib/mem.acme: -------------------------------------------------------------------------------- 1 | DO_NOT_USE = $00 2 | RAM_ROM_SWITCH = $01 3 | ITERATIONS = $02 4 | PLAY_SONG_REG1 = $03 5 | PLAY_SONG_REG2 = $04 6 | 7 | TILE_COL = $05 8 | TILE_ROW = $06 9 | C_TILE_COL = $07 10 | C_TILE_ROW = $08 11 | R_TILE_COL = $09 12 | R_TILE_ROW = $0a 13 | 14 | MAP_POS_LO_T = $0b 15 | MAP_POS_HI_T = $0c 16 | C_MAP_POS_LO = $0d 17 | C_MAP_POS_HI = $0e 18 | R_MAP_POS_LO = $0f 19 | R_MAP_POS_HI = $10 20 | C_MAP_POS_LO_T = $11 21 | C_MAP_POS_HI_T = $12 22 | R_MAP_POS_LO_T = $13 23 | R_MAP_POS_HI_T = $14 24 | 25 | SCR_POS_LO_T = $15 26 | SCR_POS_HI_T = $16 27 | C_SCR_POS_LO = $17 28 | C_SCR_POS_HI = $18 29 | R_SCR_POS_LO = $19 30 | R_SCR_POS_HI = $1a 31 | C_SCR_POS_LO_T = $1b 32 | C_SCR_POS_HI_T = $1c 33 | R_SCR_POS_LO_T = $1d 34 | R_SCR_POS_HI_T = $1e 35 | 36 | PIX_POS_LO_T = $1f 37 | PIX_POS_HI_T = $20 38 | C_PIX_POS_LO = $21 39 | C_PIX_POS_HI = $22 40 | R_PIX_POS_LO = $23 41 | R_PIX_POS_HI = $24 42 | C_PIX_POS_LO_T = $25 43 | C_PIX_POS_HI_T = $26 44 | R_PIX_POS_LO_T = $27 45 | R_PIX_POS_HI_T = $28 46 | 47 | CLR_POS_LO_T = $29 48 | CLR_POS_HI_T = $2a 49 | C_CLR_POS_HI_T = $2b 50 | R_CLR_POS_HI_T = $2c 51 | 52 | C_COPY = $2d 53 | R_COPY = $2e 54 | SCROLL_U_D = $2f 55 | SCROLL_L_R = $30 56 | SPR_COUNTER = $31 57 | PLAY = $32 58 | CTRL_Y_INVALID = $33 59 | INIT_SCREEN_LO = $34 60 | INIT_SCREEN_HI = $35 61 | 62 | SPR_I = $40; - $57 63 | SPR_Y = $58; - $6f 64 | 65 | ; zero page: $0000 - $00ff 66 | ; cpu stack: $0100 - $01ff 67 | DISK_LOADER = $0200; ~ $0400 68 | ;----------------------------------1k 69 | MEM_FOR_BASIC = $0400; - $07ff 70 | ;----------------------------------1k 71 | 72 | SPR_DATA = $080d; - $0883 73 | CODE_START = $0885; - $1fff, 6k 74 | SONG_DATA = $2000; - $2fff, 4k 75 | ;---------------------------------12k 76 | 77 | DISK_LOADER_SRC = $3000; ~ $3200 78 | DISK_INSTALLER = $4000; ~ $5b00 79 | TILE_MAP = $3000; - $8fff, 24k 80 | TILE_CLR = $9000; - $95ff, 1.5k 81 | TILE_SCR = $9600; - $9bff, 1.5k 82 | TILE_PIX = $9c00; - $bfff, 9k 83 | ;---------------------------------36k 84 | 85 | VIC_BANK = $c000; 86 | HIRES = $c000; - $dfff, 8k, 4k under I/O area 87 | SCREEN = $e000; - $e3ff, 1k 88 | SPR_FR = $e400; - $ffbf, 7k 111 sprite frames 89 | ;---------------------------------16k 90 | 91 | SPR_FR_BASE = (SPR_FR-VIC_BANK)/64 92 | SPR_PTR = SCREEN+$0400-8 93 | INIT_SONG = SONG_DATA 94 | PLAY_SONG = INIT_SONG+3 95 | -------------------------------------------------------------------------------- /lib/std.acme: -------------------------------------------------------------------------------- 1 | !cpu 6510 ; for illegal opcodes 2 | !convtab scr ; for conversion to c64 screen codes 3 | 4 | ;------------------------------------------------------------------------------- 5 | ; far branches 6 | ;------------------------------------------------------------------------------- 7 | 8 | !macro jcc .t { 9 | bcs * + 5 10 | jmp .t 11 | } 12 | 13 | !macro jcs .t { 14 | bcc * + 5 15 | jmp .t 16 | } 17 | 18 | !macro jeq .t { 19 | bne * + 5 20 | jmp .t 21 | } 22 | 23 | !macro jne .t { 24 | beq * + 5 25 | jmp .t 26 | } 27 | 28 | !macro jmi .t { 29 | bpl * + 5 30 | jmp .t 31 | } 32 | 33 | !macro jpl .t { 34 | bmi * + 5 35 | jmp .t 36 | } 37 | 38 | !macro jvc .t { 39 | bvs * + 5 40 | jmp .t 41 | } 42 | 43 | !macro jvs .t { 44 | bvc * + 5 45 | jmp .t 46 | } 47 | 48 | ;------------------------------------------------------------------------------- 49 | ; convenience branch pseudo opcodes 50 | ;------------------------------------------------------------------------------- 51 | 52 | ; 53 | ; borrow 54 | ; 55 | 56 | ; branch if borrow clear 57 | !macro bbc .l { 58 | bcs .l 59 | } 60 | 61 | ; branch if borrow set 62 | !macro bbs .l { 63 | bcc .l 64 | } 65 | 66 | ; long branch if borrow clear 67 | !macro jbc .l { 68 | bcc * + 5 69 | jmp .l 70 | } 71 | 72 | ; long branch if borrow set 73 | !macro jbs .l { 74 | bcs * + 5 75 | jmp .l 76 | } 77 | 78 | ; 79 | ; unsigned 80 | ; 81 | 82 | ; branch if below 83 | !macro bult .l { 84 | bcc .l 85 | } 86 | 87 | ; branch if below or equal 88 | !macro bule .l { 89 | beq .l 90 | bcc .l 91 | } 92 | 93 | ; branch if above 94 | !macro bugt .l { 95 | beq + 96 | bcs .l 97 | + 98 | } 99 | 100 | ; branch if above or equal 101 | !macro buge .l { 102 | bcs .l 103 | } 104 | 105 | ; 106 | ; signed 107 | ; 108 | 109 | ; branch if less 110 | !macro bslt .l { 111 | bmi .l 112 | } 113 | 114 | ; branch if less or equal 115 | !macro bsle .l { 116 | beq .l 117 | bmi .l 118 | } 119 | 120 | ; branch if greater 121 | !macro bsgt .l { 122 | beq .l 123 | bpl .l 124 | } 125 | 126 | ; branch if greater or equal 127 | !macro bsge .l { 128 | bpl .l 129 | } 130 | 131 | ;------------------------------------------------------------------------------- 132 | ; skip jumps 133 | ;------------------------------------------------------------------------------- 134 | 135 | !macro bcc { 136 | .checkmark 137 | bcc + 138 | + 139 | !if >.checkmark != >* { 140 | !warn "page boundary crossed" 141 | } 142 | } 143 | 144 | !macro bcs { 145 | .checkmark 146 | bcs + 147 | + 148 | !if >.checkmark != >* { 149 | !warn "page boundary crossed" 150 | } 151 | } 152 | 153 | !macro beq { 154 | .checkmark 155 | beq + 156 | + 157 | !if >.checkmark != >* { 158 | !warn "page boundary crossed" 159 | } 160 | } 161 | 162 | !macro bne { 163 | .checkmark 164 | bne + 165 | + 166 | !if >.checkmark != >* { 167 | !warn "page boundary crossed" 168 | } 169 | } 170 | 171 | !macro bpl { 172 | .checkmark 173 | bpl + 174 | + 175 | !if >.checkmark != >* { 176 | !warn "page boundary crossed" 177 | } 178 | } 179 | 180 | !macro bmi { 181 | .checkmark 182 | bmi + 183 | + 184 | !if >.checkmark != >* { 185 | !warn "page boundary crossed" 186 | } 187 | } 188 | 189 | !macro bvc { 190 | .checkmark 191 | bvc + 192 | + 193 | !if >.checkmark != >* { 194 | !warn "page boundary crossed" 195 | } 196 | } 197 | 198 | !macro bvs { 199 | .checkmark 200 | bvs + 201 | + 202 | !if >.checkmark != >* { 203 | !warn "page boundary crossed" 204 | } 205 | } 206 | 207 | ;------------------------------------------------------------------------------- 208 | 209 | !macro create_basic_starter .line, .start { 210 | ; here begins basic 211 | *=$0801 212 | 213 | ; end address of basic programm 214 | !word .end - 1 215 | 216 | ; line number of the basic line 217 | !word .line 218 | 219 | ; sys 220 | !by $9e 221 | 222 | ; find leading decimal digit of .start 223 | !set .i = 10000 224 | !set .digit = 0 225 | !do while .digit = 0 { 226 | !set .digit = .start / .i 227 | !set .start = .start % .i 228 | !set .i = .i / 10 229 | } 230 | 231 | !by '0' + .digit 232 | 233 | ; now output the rest 234 | !do while .i != 0 { 235 | !by '0' + .start / .i 236 | !set .start = .start % .i 237 | !set .i = .i / 10 238 | } 239 | .end 240 | } 241 | 242 | !macro create_basic_starter .start { 243 | +create_basic_starter 42, .start 244 | } 245 | 246 | ;------------------------------------------------------------------------------- 247 | 248 | VECTOR_NMI = $fffa 249 | VECTOR_RESET = $fffc 250 | VECTOR_IRQ = $fffe 251 | 252 | !macro save_regs .label { 253 | !set .offset = 3 254 | sta .label + .offset + 1 255 | stx .label + .offset + 3 256 | sty .label + .offset + 5 257 | } 258 | 259 | !macro ack_restore_rti { 260 | inc VIC_IRQ_STATUS 261 | lda #0 262 | ldx #0 263 | ldy #0 264 | rti 265 | } 266 | 267 | !macro sprite_line .v { 268 | !by .v>>16, (.v>>8)&255, .v&255 269 | } 270 | 271 | !macro flip_byte .v { 272 | !by ((.v & 1) << 7) | ((.v & 2) << 5) | ((.v & 4) << 3) | ((.v & 8) << 1) | ((.v & 16) >> 1) | ((.v & 32) >> 3) | ((.v & 64) >> 5) | ((.v & 128) >> 7) 273 | } 274 | 275 | !macro address .v { 276 | !by <.v, >.v 277 | } 278 | 279 | !macro clear_screen .v, .addr { 280 | ldx #0 281 | lda #.v 282 | - 283 | sta .addr + $0000, x 284 | sta .addr + $0100, x 285 | sta .addr + $0200, x 286 | sta .addr + $0300, x 287 | dex 288 | bne - 289 | } 290 | 291 | !macro wait .w { 292 | !if .w = 0 { 293 | ; do nothing 294 | } else { 295 | !if .w = 1 { 296 | !error "does not work for an input value of 1" 297 | } else { 298 | !if .w % 2 = 0 { 299 | !for .i, 0, .w / 2 - 1 { 300 | nop 301 | } 302 | } else { 303 | !for .i, 0, (.w-3) / 2 - 1 { 304 | nop 305 | } 306 | bit $ea 307 | } 308 | } 309 | } 310 | } 311 | 312 | !macro wait_even .w { 313 | !if .w % 2 = 0 { 314 | +wait .w 315 | } else { 316 | +wait .w + 1 317 | } 318 | } 319 | 320 | !macro wait_loop .w { 321 | !set .v = .w - 2 ; because of the ldy below 322 | !set .num_iters = (.v+1) / 5 323 | !set .rest = .v - ((.num_iters-1)* 5 + 4) 324 | 325 | !if .rest = 1 { 326 | !set .num_iters = .num_iters - 1 327 | !set .rest = .rest + 5 328 | } 329 | 330 | !if .num_iters > 255 { 331 | !error "loop to large" 332 | } 333 | 334 | !if .num_iters < 2 { 335 | +wait .w 336 | } else { 337 | ldy # .num_iters 338 | - ; here are (num_iters-1)*5 + 4 cycles 339 | dey 340 | bne - 341 | 342 | !set .rest = .v - ((.num_iters-1)* 5 + 4) 343 | +wait .rest 344 | } 345 | } 346 | 347 | RAM_ROM_SELECTION = $01 348 | RAM_ROM_DEFAULT = %00110111 349 | ALL_RAM_WITH_IO = %00110101 350 | ALL_RAM = %00110100 351 | 352 | !macro set .value, .addr { 353 | lda #.value 354 | sta .addr 355 | } 356 | 357 | !macro set16 .value, .addr { 358 | lda #<.value 359 | sta .addr 360 | lda #>.value 361 | sta .addr+1 362 | } 363 | 364 | !macro set16 .current, .value, .addr { 365 | lda #<.value 366 | sta .addr 367 | 368 | !if >.current != >.value { 369 | lda #>.value 370 | sta .addr+1 371 | } else { 372 | !warn "yeah" 373 | } 374 | } 375 | 376 | !macro copy .src, .dst { 377 | lda .src 378 | sta .dst 379 | } 380 | 381 | !macro copy_x .src, .dst { 382 | ldx .src 383 | stx .dst 384 | } 385 | 386 | !macro copy_y .src, .dst { 387 | ldy .src 388 | sty .dst 389 | } 390 | 391 | !macro inc16 .val { 392 | inc .val 393 | bcc + 394 | inc .val + 1 395 | + 396 | } 397 | 398 | BPL_OPCODE = $10 399 | BMI_OPCODE = $30 400 | BCS_OPCODE = $b0 401 | BCC_OPCODE = $90 402 | 403 | !macro rsub .val { 404 | eor #$ff 405 | sec 406 | adc .val 407 | } 408 | 409 | ;------------------------------------------------------------------------------- 410 | ; assert 411 | ;------------------------------------------------------------------------------- 412 | 413 | !macro assert .value, .addr { 414 | lda .addr 415 | cmp #.value 416 | beq + 417 | jam 418 | + 419 | } 420 | -------------------------------------------------------------------------------- /lib/vic.acme: -------------------------------------------------------------------------------- 1 | ; first raster line with backgroundcolor: 51 2 | ; 12 cycles left border + 40 cycles screen + 11 cycles right border 3 | 4 | FIRST_BADLINE = $30 5 | 6 | ; VIC constants 7 | 8 | VIC = $D000 9 | 10 | VIC_SPR_0_X = $D000 11 | VIC_SPR_0_Y = $D001 12 | VIC_SPR_1_X = $D002 13 | VIC_SPR_1_Y = $D003 14 | VIC_SPR_2_X = $D004 15 | VIC_SPR_2_Y = $D005 16 | VIC_SPR_3_X = $D006 17 | VIC_SPR_3_Y = $D007 18 | VIC_SPR_4_X = $D008 19 | VIC_SPR_4_Y = $D009 20 | VIC_SPR_5_X = $D00A 21 | VIC_SPR_5_Y = $D00B 22 | VIC_SPR_6_X = $D00C 23 | VIC_SPR_6_Y = $D00D 24 | VIC_SPR_7_X = $D00E 25 | VIC_SPR_7_Y = $D00F 26 | VIC_SPR_X_MSB = $D010 27 | 28 | VIC_SPR_COORDS = VIC_SPR_0_X 29 | 30 | ; Bit 7: Bit 8 of $D012 31 | ; Bit 6: Extended Color Modus 32 | ; Bit 5: Bitmap Mode 33 | ; Bit 4: Screen output enabled? 34 | ; Bit 3: 25 rows (24 otherwise) 35 | ; Bit 2..0: Offset in raster rows starting from the top screen edge 36 | ; 011 -> normal 37 | ; 100 -> 1 pixel down 38 | ; 010 -> 1 pixel up 39 | VIC_CONTROL_Y = $D011 40 | 41 | ; read: current line: 42 | ; write: interrupt request at line 43 | VIC_RASTER = $D012 44 | VIC_LIGHT_PEN_X = $D013 45 | VIC_LIGHT_PEN_Y = $D014 46 | VIC_SPR_ENABLE = $D015 47 | 48 | ; Bit 7..5: unused 49 | ; Bit 4: Multi-Color Mode 50 | ; Bit 3: 40 cols (on)/38 cols (off) 51 | ; Bit 2..0: Offset in Pixels starting from the left screen edge 52 | VIC_CONTROL_X = $D016 53 | 54 | VIC_SPR_EXP_Y = $D017 55 | 56 | ; Bit 7..4: Address bits 11..8 of the screen memory within the 16KB of the VIC 57 | ; Bit 3..1: Address bits 11..8 of char generator (bit 0 is unused) 58 | ; Bit 3: Bit 8 of Hires-Bitmap (in Bitmapmode) 59 | VIC_ADDR_SELECT = $D018 60 | 61 | ; read: 62 | ; Bit 7: IRQ triggered by VIC 63 | ; Bit 6..4: unused 64 | ; Bit 3: request by Lightpen 65 | ; Bit 2: request by sprite-sprite-collision (reg. $D01E) 66 | ; Bit 1: request by sprite-background-collision (reg. $D01F) 67 | ; Bit 0: request by raster line (reg. $D012) 68 | ; write: 69 | ; setting a bit = appropriate interrupt flag is cleared 70 | VIC_IRQ_STATUS = $D019 71 | 72 | ; Is the appropriate bit set here and in $D019 73 | ; an IRQ is triggered and bit 7 in $D019 is set 74 | ; 75 | ; Bit 7..4: unused 76 | ; Bit 3: IRQ triggered by lightpen 77 | ; Bit 2: IRQ triggered by S-S-collision 78 | ; Bit 1: IRQ triggered by S-B-Kollision 79 | ; Bit 0: IRQ triggered by raster line 80 | VIC_IRQ_CONTROL = $D01A 81 | 82 | VIC_SPR_PRIORITY= $D01B 83 | VIC_SPR_MULTI = $D01C 84 | VIC_SPR_EXP_X = $D01D 85 | VIC_S_S_COLL = $D01E 86 | VIC_S_B_COLL = $D01F 87 | VIC_BORDER = $D020 88 | VIC_BACKGROUND_0= $D021 89 | VIC_BACKGROUND_1= $D022 90 | VIC_BACKGROUND_2= $D023 91 | VIC_BACKGROUND_3= $D024 92 | 93 | VIC_SPR_COLOR_01= $D025 94 | VIC_SPR_COLOR_11= $D026 95 | 96 | ; color %10 in multi color mode 97 | VIC_SPR_0_COLOR = $D027 98 | VIC_SPR_1_COLOR = $D028 99 | VIC_SPR_2_COLOR = $D029 100 | VIC_SPR_3_COLOR = $D02A 101 | VIC_SPR_4_COLOR = $D02B 102 | VIC_SPR_5_COLOR = $D02C 103 | VIC_SPR_6_COLOR = $D02D 104 | VIC_SPR_7_COLOR = $D02E 105 | 106 | 107 | BLACK = $0 108 | WHITE = $1 109 | RED = $2 110 | CYAN = $3 111 | PURPLE = $4 112 | GREEN = $5 113 | BLUE = $6 114 | YELLOW = $7 115 | ORANGE = $8 116 | BROWN = $9 117 | LIGHT_RED = $a 118 | DARK_GREY = $b 119 | GREY = $c 120 | LIGHT_GREEN = $d 121 | LIGHT_BLUE = $e 122 | LIGHT_GREY = $f 123 | 124 | !macro set_raster_line_8 .line { 125 | lda #(.line%256) 126 | sta VIC_RASTER 127 | } 128 | 129 | !macro set_raster_line_9 .line { 130 | lda #(.line%256) 131 | sta VIC_RASTER 132 | 133 | ; clear or set raster msb 134 | lda VIC_CONTROL_Y 135 | !if .line < 256 { 136 | and #%01111111 137 | } else { 138 | ora #%10000000 139 | } 140 | sta VIC_CONTROL_Y 141 | } 142 | 143 | !macro set_raster_line_8 { 144 | sta VIC_RASTER 145 | } 146 | 147 | !macro set_raster_line_9 { 148 | sta VIC_RASTER 149 | 150 | ; clear raster msb 151 | lda VIC_CONTROL_1 152 | and #%01111111 153 | sta VIC_CONTROL_1 154 | } 155 | 156 | COLOR_RAM = $D800 157 | 158 | COLOR_BLACK = $0 159 | COLOR_WHITE = $1 160 | COLOR_RED_2 = $2 161 | COLOR_CYAN = $3 162 | COLOR_PURPLE = $4 163 | COLOR_GREEN_2 = $5 164 | COLOR_BLUE_2 = $6 165 | COLOR_YELLOW = $7 166 | COLOR_ORANGE = $8 167 | COLOR_BROWN = $9 168 | COLOR_RED_1 = $a 169 | COLOR_GREY_3 = $b 170 | COLOR_GREY_2 = $c 171 | COLOR_GREEN_1 = $d 172 | COLOR_BLUE_1 = $e 173 | COLOR_GREY_1 = $f 174 | -------------------------------------------------------------------------------- /map.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/leissa/c64engine/7a6d3b692173578919ff37b35eab76d7f570e5f8/map.bin -------------------------------------------------------------------------------- /pixels.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/leissa/c64engine/7a6d3b692173578919ff37b35eab76d7f570e5f8/pixels.bin -------------------------------------------------------------------------------- /raster.acme: -------------------------------------------------------------------------------- 1 | !ifdef DEBUG { 2 | !warn "bytes wasted: ", IRQ-* 3 | } 4 | 5 | !if SPRITES = 0 { 6 | !macro inc_vic_control_y { 7 | lda VIC_CONTROL_Y ; 4 8 | clc ; 2 9 | adc #1 ; 2 10 | and #%00000111 ; 2 11 | adc #CONTROL_Y_INVALID ; 2 12 | sta VIC_CONTROL_Y ; 4 13 | } ;--> 16 14 | } else { 15 | inc_vic_control_y_zone !zone { 16 | lda VIC_CONTROL_Y ; 4 17 | clc ; 2 18 | adc #1 ; 2 19 | and #%00000111 ; 2 20 | adc #CONTROL_Y_INVALID ; 2 21 | sta VIC_CONTROL_Y ; 4 22 | 23 | rts ; 6 24 | } ;--> 22 25 | } 26 | 27 | !align 255, 0 28 | IRQ !zone { 29 | ;------------------------------------------------------------------------------- 30 | ; LINE_0 31 | ;------------------------------------------------------------------------------- 32 | 33 | ; irq event ; 7 34 | ; last instruction ; 1 (min) 35 | sta restore_regs + 1 ; 4 36 | stx restore_regs + 3 ; 4 37 | sty restore_regs + 5 ; 4 38 | 39 | lda VIC_RASTER ; 4 40 | cmp #LINE_0 ; 2 41 | beq + ; 3 42 | jam 43 | + ;--> 29 44 | ; ack interrupt 45 | inc VIC_IRQ_STATUS ; 6 46 | 47 | inc VIC_RASTER ; 6 48 | +set16 .irq_line_0_plus_1, VECTOR_IRQ ; 12 49 | ;--> 24 50 | 51 | ; save stack state 52 | tsx ; 2 53 | ; begin raster stabilization 54 | cli ; 2 55 | ;--> 4 56 | 57 | ; somewhere here the next interrupt will hit 58 | +wait_even 63 - 29 - 24 - 4 59 | 60 | ;------------------------------------------------------------------------------- 61 | ; LINE_0 + 1 62 | ;------------------------------------------------------------------------------- 63 | .irq_line_0_plus_1 64 | ; irq event ; 7 65 | ; last instruction ;1-2 (because of the nop field above) 66 | ; restore stack state 67 | txs ; 2 68 | ;--> 10-11 69 | 70 | ; calculate the number of nops to skip in VSP 71 | lda #SCR_COLS-1 ; 2 72 | sec ; 2 73 | HARD_X = *+1 74 | sbc #0 ; 2 75 | lsr ; 2 76 | sta .self_modifying_branch__nops + 1 ; 4 77 | ;--> 12 78 | 79 | ; introduce an extra cycle in VSP if carry is set 80 | bcs .set_bcc ;2-3 81 | .set_bcs 82 | ldx #BCS_OPCODE ; 2 83 | bne + ; always true ; 3 84 | .set_bcc 85 | ldx #BCC_OPCODE ; 2 86 | nop ; make this path as long ; 2 87 | + 88 | stx .self_modifying_branch__lsb ; 4 89 | ;--> 11 90 | 91 | ; set up soft scroll 92 | lda #CONTROL_X ; 2 93 | clc ; 2 94 | SOFT_X = *+1 95 | adc #0 ; 2 96 | sta VIC_CONTROL_X ; 4 97 | ;--> 10 98 | 99 | +wait 63-11-12-11-10-6 100 | 101 | ; wobble check 102 | lda #LINE_0 + 2 ; 2 103 | cmp VIC_RASTER ; 4 104 | ;--> 6 105 | +bne ;3-2 106 | ; -> the raster interrupt is stable now with 3 cycles off 107 | 108 | ;------------------------------------------------------------------------------- 109 | ; LINE_0 + 2 110 | ;------------------------------------------------------------------------------- 111 | 112 | ; wobble check from above ;--> 3 113 | 114 | ; make FIRST_BADLINE a bad line 115 | !if SPRITES = 0 { 116 | lda #CONTROL_Y_INVALID ; 2 117 | } else { 118 | lda CTRL_Y_INVALID ; 3 119 | } 120 | sta VIC_CONTROL_Y ; 4 121 | ;--> 6/7 122 | 123 | lda #SCR_ROWS ; 2 124 | sec ; 2 125 | HARD_Y = *+1 126 | sbc #0 ; 2 127 | tax ; 2 128 | ;--> 8 129 | 130 | ; pre-compute VIC_CONTROL_Y value for soft-scrolling 131 | lda #7 + (SCR_ROWS+1) % 8 ; 2 132 | sec ; 2 133 | SOFT_Y = *+1 134 | sbc #0 ; 2 135 | 136 | and #%00000111 ; 2 137 | ora #CONTROL_Y_INVALID ; 2 138 | ; spill pre-computed value 139 | pha ; 3 140 | ;--> 13/14 141 | 142 | !if SPRITES = 0 { 143 | +wait_loop 63 - 3 - 6 - 8 - 13 - 20 - 4 144 | } 145 | 146 | ;------------------------------------------------------------------------------- 147 | ; FLD & line crunch 148 | ;------------------------------------------------------------------------------- 149 | 150 | .fld_loop 151 | cpx #0 ; 2 152 | beq + ; 2 (in this loop) 153 | 154 | !if SPRITES = 0 { 155 | +inc_vic_control_y ; 16 156 | +wait_loop 63 - 20 - 2 - 3 157 | } else { 158 | jsr inc_vic_control_y_zone ; 22 + 6 (jsr) 159 | lda VIC_RASTER ; 4 160 | cmp #SPRITES_TOP_Y ; 2 161 | bcs .sprite_rows_fld_wait ; 2/3 162 | +wait_loop 63 - 32 - 2 - 3 - 4 - 2 - 2 163 | } 164 | 165 | dex ; 2 166 | jmp .fld_loop ; 3 167 | + 168 | 169 | ldx HARD_Y 170 | 171 | .crunch_loop 172 | cpx #0 ; 2 173 | beq + ; 2 (in this loop) 174 | 175 | !if SPRITES = 0 { 176 | +inc_vic_control_y ; 16 177 | +wait_loop 63 - 20 - 2 - 3 178 | } else { 179 | jsr inc_vic_control_y_zone ; 22 + 6 (jsr) 180 | lda VIC_RASTER ; 4 181 | cmp #SPRITES_TOP_Y ; 2 182 | bcs .sprite_rows_crunch_wait ; 2/3 183 | +wait_loop 63 - 32 - 4 - 2 - 2 - 2 - 3 184 | } 185 | 186 | dex ; 2 187 | jmp .crunch_loop ; 3 188 | + 189 | 190 | !if SPRITES != 0 { 191 | .sprite_rows_fld_loop 192 | cpx #0 ; 2 193 | beq + ; 2 (in this loop) 194 | jsr inc_vic_control_y_zone ; 22 + 6 (jsr) 195 | 196 | .sprite_rows_fld_wait 197 | +wait_loop 44 - 32 - 2 - 3 198 | 199 | dex ; 2 200 | jmp .sprite_rows_fld_loop ; 3 201 | + 202 | 203 | ldx HARD_Y 204 | 205 | .sprite_rows_crunch_loop 206 | cpx #0 ; 2 207 | beq + ; 2 (in this loop) 208 | jsr inc_vic_control_y_zone ; 22 + 6 (jsr) 209 | 210 | .sprite_rows_crunch_wait 211 | +wait_loop 44 - 32 - 2 - 3 212 | 213 | dex ; 2 214 | jmp .sprite_rows_crunch_loop ; 3 215 | + 216 | } 217 | ; ^^^ these are always 25 raster lines ^^^ 218 | 219 | ;------------------------------------------------------------------------------- 220 | ; VSP 221 | ;------------------------------------------------------------------------------- 222 | ; make VSP line not a bad line 223 | inc VIC_CONTROL_Y ;6 224 | !if SPRITES = 0 { 225 | +wait 5 ;5 226 | } else { 227 | +wait 4 ;4 228 | } 229 | sec ;2 230 | ; introduce an extra cycle if 39 - HARD_X is odd 231 | .self_modifying_branch__lsb 232 | +bcs ;2-3 233 | 234 | .self_modifying_branch__nops 235 | ; always true and jump into nop field 236 | +bcs ;3 237 | +wait 38 ;0-38 238 | 239 | !if (>IRQ) != (>*) { 240 | !error "critical irq code in different pages" 241 | } 242 | ; generate bad line 243 | dec VIC_CONTROL_Y ;6 244 | 245 | ; 6 + 4/5 + 2 + 2/3 + 3 + 0/38 + 6 = 23-25/63 246 | 247 | ;------------------------------------------------------------------------------- 248 | ; prepare soft scroll 249 | ;------------------------------------------------------------------------------- 250 | ; reload pre-computed VIC_CONTROL_Y value 251 | pla 252 | sta VIC_CONTROL_Y 253 | and #CONTROL_Y_MASK 254 | pha 255 | 256 | ;stx VIC_BORDER ;4 257 | 258 | ;------------------------------------------------------------------------------- 259 | ; use wait time to setup sprites 260 | ;------------------------------------------------------------------------------- 261 | 262 | ; todo 263 | 264 | ;------------------------------------------------------------------------------- 265 | ; issue soft scroll 266 | ;------------------------------------------------------------------------------- 267 | 268 | pla 269 | ; wait till end of AGSP region 270 | ldy #FIRST_BADLINE+SCR_ROWS+8+1 271 | - 272 | cpy VIC_RASTER 273 | bne - 274 | 275 | sta VIC_CONTROL_Y 276 | 277 | ;------------------------------------------------------------------------------- 278 | ; sprite multiplexing 279 | ;------------------------------------------------------------------------------- 280 | 281 | !ifdef DEBUG { 282 | ldx #3 283 | stx VIC_BORDER 284 | ; inc VIC_BORDER 285 | } 286 | 287 | !if SPRITES < 4 { 288 | ldx #SPRITES 289 | } else { 290 | ldx #4 291 | } 292 | 293 | ; sprite with y = 28: 294 | ; 27--------------------|... dma disabled 295 | ; 28--------------------|... dma enabled 296 | ; 29------line 1--------|... dma enabled 297 | ; .. 298 | ; 49------line 21-------|... dma disabled 299 | ; 50---ready for next---|<-- triggerline = 28+22 300 | 301 | rotate 302 | !for .i, 0, 3 { 303 | !set r = 3-.i 304 | !zone { 305 | .check_done 306 | cpx #SPRITES 307 | bne .next_sprite 308 | .last_irq 309 | !ifdef DEVELOP { 310 | ldy VIC_RASTER 311 | cpy #$f0 312 | bcc + 313 | jam 314 | + 315 | } 316 | ldy #$f0+2 317 | sty VIC_RASTER 318 | +set16 last_irq, VECTOR_IRQ 319 | jmp out 320 | .next_sprite 321 | lda VIC_SPR_0_Y + r*4 ; get y position of physical sprite 322 | clc 323 | adc #22 ; calculate when sprite will be done, see above diagram 324 | bcs .last_irq ; if we overflow we can be sure triggerline is too high 325 | cmp #SPRITES_MAX_Y ; $f9 is the last visible line: ensure triggerline < $f8 326 | bcs .last_irq ; nothing left to do 327 | 328 | tay ; y = triggerline for next sprite 329 | sbc VIC_RASTER ; a = triggerline - rasterline - 1 (omit sec) 330 | bcc .display_sprite ; rasterline >= triggerline: display next sprite 331 | cmp #2 ; rasterline < triggerline, a = #lines left - 1 332 | bcs .set_interrupt ; at least 3 lines left to set an interrupt 333 | dey ; fewer than 3 lines left, prepare to poll 334 | - 335 | cpy VIC_RASTER 336 | bcs - ; we might be on a badline: use dey, bcs instead of bne 337 | bcc .display_sprite ; branch always 338 | 339 | .set_interrupt 340 | stx SPR_COUNTER 341 | sty VIC_RASTER 342 | +set16 .next_irq, VECTOR_IRQ 343 | jmp out 344 | 345 | .next_irq 346 | sta restore_regs + 1 347 | stx restore_regs + 3 348 | sty restore_regs + 5 349 | ; !ifdef DEBUG { 350 | ; inc VIC_BORDER 351 | ; } 352 | ldx SPR_COUNTER 353 | !ifdef DEBUG { 354 | stx VIC_BORDER 355 | } 356 | 357 | .display_sprite 358 | ldy SPR_I, x 359 | inx 360 | 361 | ; y-coord 362 | lda SPR_Y, y 363 | 364 | ; are we too late? 365 | cmp VIC_RASTER 366 | bcs .do_display_sprite 367 | lda #SPRITES_MAX_Y 368 | cmp VIC_RASTER 369 | bcc .last_irq 370 | jmp .check_done 371 | 372 | .do_display_sprite 373 | sta VIC_SPR_0_Y + r*4 374 | sta VIC_SPR_0_Y + r*4 + 2 375 | 376 | ; x-coord 377 | lda SPR_X, y 378 | asl 379 | sta VIC_SPR_0_X + r*4 380 | sta VIC_SPR_0_X + r*4 + 2 381 | 382 | ; x-msb 383 | bcc .clear_x_msb 384 | .set_x_msb 385 | lda # %00000011 << 2*r 386 | ora VIC_SPR_X_MSB 387 | bne + ; always true 388 | .clear_x_msb 389 | lda # 1 { 491 | !for .i, 0, SPRITES-2 { 492 | ldy SPR_I + .i + 1 493 | !if .i % 2 = 0 { 494 | !set .back_0 = * 495 | } else { 496 | !set .back_1 = * 497 | } 498 | ldx SPR_I + .i 499 | lda SPR_Y, y ; A: r-elem 500 | cmp SPR_Y, x ; M: l-elem 501 | ; swap if A < M 502 | ; skip if A >= M 503 | bcs + 504 | stx SPR_I + .i + 1 505 | sty SPR_I + .i 506 | !if .i != 0 { 507 | !if .i % 2 = 0 { 508 | bcc .back_1 ; always true 509 | } else { 510 | bcc .back_0 ; always true 511 | } 512 | } 513 | + 514 | } 515 | } 516 | 517 | !ifdef DEBUG { 518 | ldx #1 519 | stx VIC_BORDER 520 | ; dec VIC_BORDER 521 | } 522 | 523 | !ifdef DEVELOP { 524 | lda $d011 525 | and #$80 526 | bne + 527 | lda VIC_RASTER 528 | bmi + 529 | cmp #LINE_0-1 ; ok if VIC_RASTER < LINE_0-1 530 | bcc + 531 | jam ; if there is too little time, stop execution 532 | + 533 | } 534 | 535 | +set_raster_line_8 LINE_0 536 | +set16 IRQ, VECTOR_IRQ 537 | 538 | out 539 | !ifdef DEBUG { 540 | ldx #0 541 | stx VIC_BORDER 542 | ; dec VIC_BORDER 543 | } 544 | 545 | inc VIC_IRQ_STATUS 546 | 547 | restore_regs 548 | lda #0 549 | ldx #0 550 | ldy #0 551 | rti 552 | 553 | EMPTY_INTERRUPT = *-1 554 | } 555 | -------------------------------------------------------------------------------- /screen.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/leissa/c64engine/7a6d3b692173578919ff37b35eab76d7f570e5f8/screen.bin -------------------------------------------------------------------------------- /scroll.acme: -------------------------------------------------------------------------------- 1 | SCROLL_COLS = SCR_COLS 2 | SCROLL_ROWS = SCR_ROWS-2 3 | 4 | INC_HARD_Y !zone { 5 | inc HARD_Y 6 | lda #SCR_ROWS+1 7 | cmp HARD_Y 8 | bne .return 9 | 10 | lda #0 11 | sta HARD_Y 12 | 13 | lda HARD_X 14 | sec 15 | sbc #16 16 | sta HARD_X 17 | clc 18 | adc #SCR_COLS 19 | cmp #SCR_COLS 20 | bcs .return ; jmp if A < 40 21 | sta HARD_X 22 | inc HARD_Y 23 | 24 | .return 25 | rts 26 | } 27 | 28 | DEC_HARD_Y !zone { 29 | dec HARD_Y 30 | bpl .return 31 | 32 | lda #SCR_ROWS 33 | sta HARD_Y 34 | 35 | lda HARD_X 36 | clc 37 | adc #16 38 | sta HARD_X 39 | sec 40 | sbc #SCR_COLS 41 | bmi .return 42 | sta HARD_X 43 | dec HARD_Y 44 | 45 | .return 46 | rts 47 | } 48 | 49 | !macro wrap_inc .mem, .inc, .and, .l { 50 | lda .mem 51 | clc 52 | adc #.inc 53 | and #.and-1 ; assumes 2^x = .and 54 | sta .mem 55 | bne .l 56 | } 57 | 58 | !macro wrap_dec .mem, .dec, .and, .l { 59 | lda .mem 60 | sec 61 | sbc #.dec 62 | and #.and-1 ; assumes 2^x = .and 63 | sta .mem 64 | bcs .l 65 | } 66 | 67 | !macro wrap_add .lo, .hi, .add, .and { 68 | clc 69 | 70 | lda .lo 71 | adc #(.add % 256) 72 | sta .lo 73 | !if .add < 256 { 74 | bcc + 75 | } 76 | lda .hi 77 | adc #(.add / 256) 78 | and #.and-1 ; assumes 2^x = .and 79 | sta .hi 80 | + 81 | } 82 | 83 | !macro wrap_sub .lo, .hi, .sub, .and { 84 | sec 85 | 86 | lda .lo 87 | sbc #(.sub % 256) 88 | sta .lo 89 | !if .sub < 256 { 90 | bcs + 91 | } 92 | lda .hi 93 | sbc #(.sub / 256) 94 | and #.and-1 ; assumes 2^x = .and 95 | sta .hi 96 | + 97 | } 98 | 99 | SCROLL_U !zone { 100 | ; lda VIC_SPR_0_Y 101 | ; cmp #73 102 | ; beq+ 103 | ; !for .i, 0, 7 { 104 | ; ;dec VIC_SPR_0_Y + .i*2 105 | ; } 106 | ;+ 107 | 108 | +wrap_dec SOFT_Y, SCROLL_SPEED, 8, .check_copy_tiles 109 | jsr DEC_HARD_Y 110 | rts 111 | 112 | .check_copy_tiles 113 | ; lda SOFT_Y 114 | !if SCROLL_SPEED = 2 { cmp #2 } else { cmp #3 } 115 | beq .prepare_copy_tiles 116 | rts 117 | .prepare_copy_tiles 118 | lda #COPY_COL_FRAMES 119 | sta C_COPY 120 | 121 | lda TILE_ROW 122 | sec 123 | sbc #1 124 | bcs + 125 | adc #TILE_ROWS 126 | dec C_MAP_POS_HI 127 | dec R_MAP_POS_HI 128 | + 129 | sta TILE_ROW 130 | +wrap_sub C_SCR_POS_LO, C_SCR_POS_HI, SCROLL_COLS, 4 131 | +wrap_sub R_SCR_POS_LO, R_SCR_POS_HI, SCROLL_COLS, 4 132 | +wrap_sub C_PIX_POS_LO, C_PIX_POS_HI, 8*SCROLL_COLS, 8*4 133 | +wrap_sub R_PIX_POS_LO, R_PIX_POS_HI, 8*SCROLL_COLS, 8*4 134 | 135 | lda SCROLL_U_D 136 | beq + 137 | 138 | sec 139 | lda C_MAP_POS_HI 140 | sbc #(SCROLL_ROWS-1)/TILE_ROWS 141 | sta C_MAP_POS_HI 142 | +wrap_sub C_SCR_POS_LO, C_SCR_POS_HI, (SCROLL_ROWS-1)*SCROLL_COLS, 4 143 | +wrap_sub C_PIX_POS_LO, C_PIX_POS_HI, 8*(SCROLL_ROWS-1)*SCROLL_COLS, 8*4 144 | 145 | lda #0 146 | sta SCROLL_U_D 147 | + 148 | rts 149 | } 150 | 151 | SCROLL_D !zone { 152 | ; !for .i, 0, 7 { 153 | ; ;inc VIC_SPR_0_Y + .i*2 154 | ; } 155 | 156 | +wrap_inc SOFT_Y, SCROLL_SPEED, 8, .check_copy_tiles 157 | jsr INC_HARD_Y 158 | rts 159 | 160 | .check_copy_tiles 161 | ; lda SOFT_Y 162 | cmp #4 163 | beq .prepare_copy_tiles 164 | rts 165 | .prepare_copy_tiles 166 | lda #COPY_COL_FRAMES 167 | sta C_COPY 168 | 169 | lda TILE_ROW 170 | clc 171 | adc #1 172 | cmp #TILE_ROWS 173 | bcc + 174 | sbc #TILE_ROWS 175 | inc C_MAP_POS_HI 176 | inc R_MAP_POS_HI 177 | + 178 | sta TILE_ROW 179 | +wrap_add C_SCR_POS_LO, C_SCR_POS_HI, SCROLL_COLS, 4 180 | +wrap_add R_SCR_POS_LO, R_SCR_POS_HI, SCROLL_COLS, 4 181 | +wrap_add C_PIX_POS_LO, C_PIX_POS_HI, 8*SCROLL_COLS, 8*4 182 | +wrap_add R_PIX_POS_LO, R_PIX_POS_HI, 8*SCROLL_COLS, 8*4 183 | 184 | lda SCROLL_U_D 185 | bne + 186 | 187 | clc 188 | lda C_MAP_POS_HI 189 | adc #(SCROLL_ROWS-1)/TILE_ROWS 190 | sta C_MAP_POS_HI 191 | +wrap_add C_SCR_POS_LO, C_SCR_POS_HI, (SCROLL_ROWS-1)*SCROLL_COLS, 4 192 | +wrap_add C_PIX_POS_LO, C_PIX_POS_HI, 8*(SCROLL_ROWS-1)*SCROLL_COLS, 8*4 193 | 194 | lda #1 195 | sta SCROLL_U_D 196 | + 197 | rts 198 | } 199 | 200 | SCROLL_L !zone { 201 | ; !for .i, 0, 7 { 202 | ; ;dec VIC_SPR_0_X + .i*2 203 | ; } 204 | 205 | +wrap_inc SOFT_X, SCROLL_SPEED, 8, .check_copy_tiles 206 | inc HARD_X 207 | lda #SCR_COLS 208 | cmp HARD_X 209 | bne + 210 | 211 | lda #0 212 | sta HARD_X 213 | jsr DEC_HARD_Y 214 | + 215 | rts 216 | 217 | .check_copy_tiles 218 | ; lda SOFT_X 219 | cmp #4 220 | beq .prepare_copy_tiles 221 | rts 222 | .prepare_copy_tiles 223 | lda #COPY_ROW_FRAMES 224 | sta R_COPY 225 | 226 | lda TILE_COL 227 | sec 228 | sbc #1 229 | bcs + 230 | adc #TILE_COLS 231 | dec C_MAP_POS_LO 232 | dec R_MAP_POS_LO 233 | + 234 | sta TILE_COL 235 | +wrap_sub C_SCR_POS_LO, C_SCR_POS_HI, 1, 4 236 | +wrap_sub R_SCR_POS_LO, R_SCR_POS_HI, 1, 4 237 | +wrap_sub C_PIX_POS_LO, C_PIX_POS_HI, 8, 8*4 238 | +wrap_sub R_PIX_POS_LO, R_PIX_POS_HI, 8, 8*4 239 | 240 | lda SCROLL_L_R 241 | beq + 242 | 243 | sec 244 | lda R_MAP_POS_LO 245 | sbc #(SCROLL_COLS-1)/TILE_COLS 246 | sta R_MAP_POS_LO 247 | +wrap_sub R_SCR_POS_LO, R_SCR_POS_HI, SCROLL_COLS-1, 4 248 | +wrap_sub R_PIX_POS_LO, R_PIX_POS_HI, 8*(SCROLL_COLS-1), 8*4 249 | 250 | lda #0 251 | sta SCROLL_L_R 252 | + 253 | rts 254 | } 255 | 256 | SCROLL_R !zone { 257 | ; !for .i, 0, 7 { 258 | ; ;inc VIC_SPR_0_X + .i*2 259 | ; } 260 | 261 | +wrap_dec SOFT_X, SCROLL_SPEED, 8, .check_copy_tiles 262 | dec HARD_X 263 | bpl + 264 | 265 | lda #SCR_COLS-1 266 | sta HARD_X 267 | jsr INC_HARD_Y 268 | + 269 | rts 270 | 271 | .check_copy_tiles 272 | ; lda SOFT_X 273 | !if SCROLL_SPEED = 2 { cmp #2 } else { cmp #3 } 274 | beq .prepare_copy_tiles 275 | rts 276 | .prepare_copy_tiles 277 | lda #COPY_ROW_FRAMES 278 | sta R_COPY 279 | 280 | lda TILE_COL 281 | clc 282 | adc #1 283 | cmp #TILE_COLS 284 | bcc + 285 | sbc #TILE_COLS 286 | inc C_MAP_POS_LO 287 | inc R_MAP_POS_LO 288 | + 289 | sta TILE_COL 290 | +wrap_add C_SCR_POS_LO, C_SCR_POS_HI, 1, 4 291 | +wrap_add R_SCR_POS_LO, R_SCR_POS_HI, 1, 4 292 | +wrap_add C_PIX_POS_LO, C_PIX_POS_HI, 8, 8*4 293 | +wrap_add R_PIX_POS_LO, R_PIX_POS_HI, 8, 8*4 294 | 295 | lda SCROLL_L_R 296 | bne + 297 | 298 | clc 299 | lda R_MAP_POS_LO 300 | adc #(SCROLL_COLS-1)/TILE_COLS 301 | sta R_MAP_POS_LO 302 | +wrap_add R_SCR_POS_LO, R_SCR_POS_HI, SCROLL_COLS-1, 4 303 | +wrap_add R_PIX_POS_LO, R_PIX_POS_HI, 8*(SCROLL_COLS-1), 8*4 304 | 305 | lda #1 306 | sta SCROLL_L_R 307 | + 308 | rts 309 | } 310 | -------------------------------------------------------------------------------- /snd/transylvanian.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/leissa/c64engine/7a6d3b692173578919ff37b35eab76d7f570e5f8/snd/transylvanian.bin -------------------------------------------------------------------------------- /snd/transylvanian.sng: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/leissa/c64engine/7a6d3b692173578919ff37b35eab76d7f570e5f8/snd/transylvanian.sng -------------------------------------------------------------------------------- /spr/hero.raw: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/leissa/c64engine/7a6d3b692173578919ff37b35eab76d7f570e5f8/spr/hero.raw -------------------------------------------------------------------------------- /spr/hero.spd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/leissa/c64engine/7a6d3b692173578919ff37b35eab76d7f570e5f8/spr/hero.spd -------------------------------------------------------------------------------- /tiles.acme: -------------------------------------------------------------------------------- 1 | !macro copy_tile_char .char { 2 | ldy #0 3 | lda TILE_CLR+(.char*TILES), x 4 | sta (CLR_POS_LO_T), y 5 | 6 | lda TILE_SCR+(.char*TILES), x 7 | sta (SCR_POS_LO_T), y 8 | 9 | lda #ALL_RAM 10 | sta RAM_ROM_SELECTION 11 | 12 | !for .row, 0, 7 { 13 | lda TILE_PIX+(.char*8*TILES)+(.row*TILES), x 14 | sta (PIX_POS_LO_T), y 15 | !if .row != 7 { 16 | iny 17 | } 18 | } 19 | 20 | lda #ALL_RAM_WITH_IO 21 | sta RAM_ROM_SELECTION 22 | 23 | rts 24 | } 25 | 26 | copy_tile_char0 !zone { +copy_tile_char 0 } 27 | copy_tile_char1 !zone { +copy_tile_char 1 } 28 | copy_tile_char2 !zone { +copy_tile_char 2 } 29 | copy_tile_char3 !zone { +copy_tile_char 3 } 30 | copy_tile_char4 !zone { +copy_tile_char 4 } 31 | copy_tile_char5 !zone { +copy_tile_char 5 } 32 | 33 | !macro iterate_source_pointers .cols, .map_pos { 34 | !if .cols = 1 { 35 | !set .tile_char = C_TILE_COL 36 | } else { 37 | !set .tile_char = R_TILE_ROW 38 | } 39 | 40 | !if .cols = 1 or TILE_ROWS != 2 { 41 | lda .tile_char 42 | adc #1 43 | !if .cols = 1 { 44 | cmp #TILE_COLS 45 | } else { 46 | cmp #TILE_ROWS 47 | } 48 | sta .tile_char 49 | bcc + 50 | clc 51 | lda #0 52 | sta .tile_char 53 | } 54 | 55 | !if .cols = 1 { 56 | inc .map_pos + 1 57 | } else { 58 | !if TILE_ROWS = 2 { 59 | lda .tile_char 60 | adc #1 61 | and #1 62 | sta .tile_char 63 | bne + 64 | } 65 | 66 | inc .map_pos + 2 67 | } 68 | + 69 | } 70 | 71 | !macro iterate_destination_pointers .cols { 72 | ; pixel pointer 73 | lda PIX_POS_LO_T 74 | adc #(8*.cols % 256) ; + 64 75 | sta PIX_POS_LO_T 76 | !if .cols = 1 { 77 | bcc+ 78 | } 79 | lda PIX_POS_HI_T 80 | adc #(8*.cols / 256) ; + 256 81 | and #%11011111 ; modulo 8192 (but keep upper bits) 82 | sta PIX_POS_HI_T ; next pixel position to start from 83 | + 84 | ; color pointers 85 | lda SCR_POS_LO_T 86 | adc #.cols 87 | sta SCR_POS_LO_T ; next screen position to start from 88 | sta CLR_POS_LO_T 89 | bcc + 90 | 91 | lda CLR_POS_HI_T 92 | adc #0 93 | and #%11111011 ; modulo 1024 (but keep upper bits) 94 | sta CLR_POS_HI_T 95 | 96 | adc #%00001000 97 | sta SCR_POS_HI_T 98 | + 99 | } 100 | 101 | ; depends on TILE_COLS and TILE_ROWS 102 | ;select_and_copy_tile_char !zone { 103 | ; !for .char, 0, 5 { 104 | ; !if .char != 5 { 105 | ; !if .char != 0 { 106 | ; cmp #.char 107 | ; } 108 | ; bne + 109 | ; } 110 | ; !if .char = 0 { jsr copy_tile_char0 } 111 | ; !if .char = 1 { jsr copy_tile_char1 } 112 | ; !if .char = 2 { jsr copy_tile_char2 } 113 | ; !if .char = 3 { jsr copy_tile_char3 } 114 | ; !if .char = 4 { jsr copy_tile_char4 } 115 | ; !if .char = 5 { jsr copy_tile_char5 } 116 | ; rts 117 | ;+ 118 | ; } 119 | ;} 120 | 121 | !macro init_pointers .cols { 122 | !if .cols = 1 { 123 | !set .tile_col = C_TILE_COL 124 | !set .tile_row = C_TILE_ROW 125 | !set .map_pos_lo = C_MAP_POS_LO 126 | !set .map_pos_hi = C_MAP_POS_HI 127 | !set .pix_pos_lo = C_PIX_POS_LO 128 | !set .pix_pos_hi = C_PIX_POS_HI 129 | !set .scr_pos_lo = C_SCR_POS_LO 130 | !set .scr_pos_hi = C_SCR_POS_HI 131 | !set .map_pos_lo_t = C_MAP_POS_LO_T 132 | !set .map_pos_hi_t = C_MAP_POS_HI_T 133 | !set .pix_pos_lo_t = C_PIX_POS_LO_T 134 | !set .pix_pos_hi_t = C_PIX_POS_HI_T 135 | !set .scr_pos_lo_t = C_SCR_POS_LO_T 136 | !set .scr_pos_hi_t = C_SCR_POS_HI_T 137 | !set .clr_pos_hi_t = C_CLR_POS_HI_T 138 | } else { 139 | !set .tile_col = R_TILE_COL 140 | !set .tile_row = R_TILE_ROW 141 | !set .map_pos_lo = R_MAP_POS_LO 142 | !set .map_pos_hi = R_MAP_POS_HI 143 | !set .pix_pos_lo = R_PIX_POS_LO 144 | !set .pix_pos_hi = R_PIX_POS_HI 145 | !set .scr_pos_lo = R_SCR_POS_LO 146 | !set .scr_pos_hi = R_SCR_POS_HI 147 | !set .map_pos_lo_t = R_MAP_POS_LO_T 148 | !set .map_pos_hi_t = R_MAP_POS_HI_T 149 | !set .pix_pos_lo_t = R_PIX_POS_LO_T 150 | !set .pix_pos_hi_t = R_PIX_POS_HI_T 151 | !set .scr_pos_lo_t = R_SCR_POS_LO_T 152 | !set .scr_pos_hi_t = R_SCR_POS_HI_T 153 | !set .clr_pos_hi_t = R_CLR_POS_HI_T 154 | } 155 | lda TILE_COL 156 | sta .tile_col 157 | 158 | lda TILE_ROW 159 | sta .tile_row 160 | 161 | lda .map_pos_lo 162 | sta .map_pos_lo_t 163 | 164 | clc 165 | 166 | lda .map_pos_hi 167 | adc #>TILE_MAP 168 | clc 169 | sta .map_pos_hi_t 170 | 171 | lda .pix_pos_hi 172 | adc #>HIRES 173 | sta .pix_pos_hi_t 174 | 175 | lda .pix_pos_lo 176 | sta .pix_pos_lo_t 177 | 178 | lda .scr_pos_hi 179 | adc #>SCREEN 180 | sta .scr_pos_hi_t 181 | 182 | lda .scr_pos_hi 183 | adc #>COLOR_RAM 184 | sta .clr_pos_hi_t 185 | 186 | lda .scr_pos_lo 187 | sta .scr_pos_lo_t 188 | } 189 | 190 | !macro copy_tile_chars .cols, .count { 191 | !if .cols = 1 { 192 | !set .tile_col_t = C_TILE_COL 193 | !set .tile_row_t = C_TILE_ROW 194 | !set .map_pos_lo_t = C_MAP_POS_LO_T 195 | !set .map_pos_hi_t = C_MAP_POS_HI_T 196 | !set .pix_pos_lo_t = C_PIX_POS_LO_T 197 | !set .pix_pos_hi_t = C_PIX_POS_HI_T 198 | !set .scr_pos_lo_t = C_SCR_POS_LO_T 199 | !set .scr_pos_hi_t = C_SCR_POS_HI_T 200 | !set .clr_pos_hi_t = C_CLR_POS_HI_T 201 | } else { 202 | !set .tile_col_t = R_TILE_COL 203 | !set .tile_row_t = R_TILE_ROW 204 | !set .map_pos_lo_t = R_MAP_POS_LO_T 205 | !set .map_pos_hi_t = R_MAP_POS_HI_T 206 | !set .pix_pos_lo_t = R_PIX_POS_LO_T 207 | !set .pix_pos_hi_t = R_PIX_POS_HI_T 208 | !set .scr_pos_lo_t = R_SCR_POS_LO_T 209 | !set .scr_pos_hi_t = R_SCR_POS_HI_T 210 | !set .clr_pos_hi_t = R_CLR_POS_HI_T 211 | } 212 | lda .map_pos_lo_t 213 | sta .next_tile_char + 1 214 | 215 | lda .map_pos_hi_t 216 | sta .next_tile_char + 2 217 | 218 | lda .scr_pos_lo_t 219 | sta SCR_POS_LO_T 220 | sta CLR_POS_LO_T 221 | 222 | lda .scr_pos_hi_t 223 | sta SCR_POS_HI_T 224 | 225 | lda .clr_pos_hi_t 226 | sta CLR_POS_HI_T 227 | 228 | lda .pix_pos_lo_t 229 | sta PIX_POS_LO_T 230 | 231 | lda .pix_pos_hi_t 232 | sta PIX_POS_HI_T 233 | 234 | lda #.count 235 | sta ITERATIONS 236 | 237 | clc 238 | .next_tile_char 239 | ldx TILE_MAP 240 | 241 | ; pixel pointer 242 | lda .tile_row_t 243 | beq + 244 | lda #TILE_COLS ; a = TILE_COLS * tile_row (TILE_ROWS = 2) 245 | + 246 | adc .tile_col_t 247 | 248 | ; jsr select_and_copy_tile_char 249 | 250 | !for .char, 0, 5 { 251 | !if .char != 5 { 252 | !if .char != 0 { 253 | cmp #.char 254 | } 255 | bne + 256 | } 257 | !if .char = 0 { jsr copy_tile_char0 } 258 | !if .char = 1 { jsr copy_tile_char1 } 259 | !if .char = 2 { jsr copy_tile_char2 } 260 | !if .char = 3 { jsr copy_tile_char3 } 261 | !if .char = 4 { jsr copy_tile_char4 } 262 | !if .char = 5 { jsr copy_tile_char5 } 263 | !if .char != 5 { bne .iterate_pointers } 264 | + 265 | } 266 | 267 | .iterate_pointers 268 | clc 269 | +iterate_source_pointers .cols, .next_tile_char 270 | +iterate_destination_pointers .cols 271 | dec ITERATIONS 272 | bne .next_tile_char 273 | 274 | .exit 275 | lda .next_tile_char + 1 276 | sta .map_pos_lo_t 277 | 278 | lda .next_tile_char + 2 279 | sta .map_pos_hi_t 280 | 281 | lda SCR_POS_LO_T 282 | sta .scr_pos_lo_t 283 | 284 | lda SCR_POS_HI_T 285 | sta .scr_pos_hi_t 286 | 287 | lda CLR_POS_HI_T 288 | sta .clr_pos_hi_t 289 | 290 | lda PIX_POS_LO_T 291 | sta .pix_pos_lo_t 292 | 293 | lda PIX_POS_HI_T 294 | sta .pix_pos_hi_t 295 | } 296 | 297 | copy_col_tiles1 !zone { 298 | +init_pointers 1 299 | +copy_tile_chars 1, SCROLL_COLS / COPY_COL_FRAMES 300 | rts 301 | } 302 | 303 | copy_col_tiles2 !zone { 304 | +copy_tile_chars 1, SCROLL_COLS / COPY_COL_FRAMES + ((SCROLL_COLS % COPY_COL_FRAMES) != 0) 305 | rts 306 | } 307 | 308 | copy_row_tiles1 !zone { 309 | +init_pointers SCR_COLS 310 | +copy_tile_chars SCR_COLS, SCROLL_ROWS / COPY_ROW_FRAMES 311 | rts 312 | } 313 | 314 | copy_row_tiles2 !zone { 315 | +copy_tile_chars SCR_COLS, SCROLL_ROWS / COPY_ROW_FRAMES + ((SCROLL_ROWS % COPY_ROW_FRAMES) != 0) 316 | rts 317 | } 318 | 319 | COPY_TILES !zone { 320 | ldy C_COPY 321 | bne .check_copy_col_tiles1 322 | jsr COPY_ROW_TILES 323 | rts 324 | .check_copy_col_tiles1 325 | dey 326 | sty C_COPY 327 | cpy #COPY_COL_FRAMES-1 328 | bne .check_copy_col_tiles2 329 | jsr copy_col_tiles1 330 | rts 331 | .check_copy_col_tiles2 332 | jsr copy_col_tiles2 333 | rts 334 | } 335 | 336 | COPY_ROW_TILES !zone { 337 | ldy R_COPY 338 | bne .check_copy_row_tiles1 339 | rts 340 | .check_copy_row_tiles1 341 | dey 342 | sty R_COPY 343 | cpy #COPY_ROW_FRAMES-1 344 | bne .check_copy_row_tiles2 345 | jsr copy_row_tiles1 346 | rts 347 | .check_copy_row_tiles2 348 | jsr copy_row_tiles2 349 | rts 350 | } 351 | -------------------------------------------------------------------------------- /toys/color_matrix.acme: -------------------------------------------------------------------------------- 1 | !to "color_matrix.prg", cbm ; output program 2 | !sl "labels.l" ; create label file for vice 3 | !cpu 6510 ; for illegal opcodes 4 | !convtab scr ; for conversion to c64 screen codes 5 | 6 | !source "../lib/mem.acme" 7 | !source "../lib/vic.acme" 8 | !source "../lib/cia.acme" 9 | !source "../lib/std.acme" 10 | 11 | LAST_LINE = $fa 12 | START = $080d 13 | +create_basic_starter START 14 | *=START 15 | 16 | !zone { 17 | ;------------------------------------------------------------------------------- 18 | ; disable all basic, kernal and irq crap 19 | ;------------------------------------------------------------------------------- 20 | 21 | ; set empty interrupt routine 22 | +set16 EMPTY_INTERRUPT, VECTOR_NMI 23 | +set16 EMPTY_INTERRUPT, VECTOR_IRQ 24 | 25 | ; disable IRQs 26 | sei 27 | 28 | ; disable ROMs 29 | +set ALL_RAM_WITH_IO, RAM_ROM_SELECTION 30 | +disable_timer_interrupts 31 | 32 | lda #0 33 | ; no IRQs 34 | sta VIC_IRQ_CONTROL 35 | ; set timer A to 0 36 | sta CIA2_TIMER_A_LO 37 | sta CIA2_TIMER_A_HI 38 | 39 | ; trigger timer A interrupt 40 | +set %10000001, CIA2_INTERRUPT_CONTROL 41 | +set %00000001, CIA2_CONTROL_TIMER_A 42 | 43 | ; reset stack 44 | ldx #$ff 45 | txs 46 | 47 | ; just clear this flag and never ever touch this again 48 | cld 49 | 50 | ; -> NMI is disabled as soon as EMPTY_INTERRUPT has been triggered since we will never ever ack NMI again 51 | ; -> zero page completely free on this spot except for the special regs $00 and $01 52 | 53 | ;------------------------------------------------------------------------------- 54 | ; setup VIC 55 | ;------------------------------------------------------------------------------- 56 | 57 | ; select VIC area: bank 1 58 | lda CIA2_DATA_PORT_A 59 | and #%11111100 60 | ora #%00000010 61 | sta CIA2_DATA_PORT_A 62 | 63 | ; select screen bank 15, hires-bank 0 64 | lda #%11110000 65 | sta VIC_ADDR_SELECT 66 | 67 | ;------------------------------------------------------------------------------- 68 | ; setup test stuff 69 | ;------------------------------------------------------------------------------- 70 | 71 | ; clear ram 72 | lda #12 73 | ldx #0 74 | - 75 | sta SCREEN + $0000, x 76 | sta SCREEN + $0100, x 77 | sta SCREEN + $0200, x 78 | sta SCREEN + $0300, x 79 | dex 80 | bne - 81 | 82 | ; clear ram 83 | lda #COLOR_GREY_2 84 | ldx #0 85 | - 86 | sta COLOR_RAM + $0000, x 87 | sta COLOR_RAM + $0100, x 88 | sta COLOR_RAM + $0200, x 89 | sta COLOR_RAM + $0300, x 90 | dex 91 | bne - 92 | 93 | ;------------------------------------------------------------------------------- 94 | ; setup raster irq 95 | ;------------------------------------------------------------------------------- 96 | 97 | ; ack all interrupts which might have happend 98 | +set $ff, VIC_IRQ_STATUS 99 | 100 | +set16 IRQ, VECTOR_IRQ 101 | +set_raster_line_9 LAST_LINE 102 | +set 1, VIC_IRQ_CONTROL 103 | ; enable IRQs 104 | cli 105 | 106 | - 107 | ; some 7 cycle garbage instructions 108 | lda ($f0), y 109 | lda ($f0, x) 110 | lda ($f0), y 111 | lda ($f0, x) 112 | lda ($f0), y 113 | sec ; 2 114 | +bcs ; 3 115 | jmp - 116 | } 117 | 118 | state 119 | !by 0 120 | 121 | IRQ !zone { 122 | ;------------------------------------------------------------------------------- 123 | ; LAST_LINE 124 | ;------------------------------------------------------------------------------- 125 | +save_regs .out 126 | 127 | inc VIC_BORDER 128 | 129 | lda state 130 | bne .state_1 131 | 132 | .state_0 133 | ldx #$0f 134 | - 135 | lda #0 136 | !for .row, 0, 15 { 137 | sta COLOR_RAM + .row * 40, x 138 | clc 139 | adc #1 140 | } 141 | dex 142 | bpl - 143 | 144 | +set 1, state 145 | jmp .out_dec_border 146 | 147 | .state_1 148 | ldx #$0f 149 | - 150 | txa 151 | !for .row, 0, 15 { 152 | sta COLOR_RAM + .row * 40, x 153 | } 154 | dex 155 | bpl - 156 | 157 | +set 0, state 158 | 159 | .out_dec_border 160 | dec VIC_BORDER 161 | 162 | .out 163 | +ack_restore_rti 164 | EMPTY_INTERRUPT = *-1 165 | } 166 | -------------------------------------------------------------------------------- /toys/make_palette.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | import math 4 | 5 | colors = [ 6 | ([0x00, 0x00, 0x00], "Black" ), 7 | ([0xFF, 0xFF, 0xFF], "White" ), 8 | ([0x68, 0x37, 0x2B], "Red" ), 9 | ([0x70, 0xA4, 0xB2], "Cyan" ), 10 | ([0x6F, 0x3D, 0x86], "Purple" ), 11 | ([0x58, 0x8D, 0x43], "Green" ), 12 | ([0x35, 0x28, 0x79], "Blue" ), 13 | ([0xB8, 0xC7, 0x6F], "Yellow" ), 14 | ([0x6F, 0x4F, 0x25], "Orange" ), 15 | ([0x43, 0x39, 0x00], "Brown" ), 16 | ([0x9A, 0x67, 0x59], "Light Red" ), 17 | ([0x44, 0x44, 0x44], "Dark Grey" ), 18 | ([0x6C, 0x6C, 0x6C], "Grey" ), 19 | ([0x9A, 0xD2, 0x84], "Light Green" ), 20 | ([0x6C, 0x5E, 0xB5], "Light Blue" ), 21 | ([0x95, 0x95, 0x95], "Light Grey" ), 22 | ] 23 | 24 | BLACK = 0x0 25 | WHITE = 0x1 26 | RED = 0x2 27 | CYAN = 0x3 28 | PURPLE = 0x4 29 | GREEN = 0x5 30 | BLUE = 0x6 31 | YELLOW = 0x7 32 | ORANGE = 0x8 33 | BROWN = 0x9 34 | LIGHT_RED = 0xa 35 | DARK_GREY = 0xb 36 | GREY = 0xc 37 | LIGHT_GREEN = 0xd 38 | LIGHT_BLUE = 0xe 39 | LIGHT_GREY = 0xf 40 | 41 | def distance(x, y): 42 | (xr, xg, xb), x_name = x 43 | (yr, yg, yb), y_name = y 44 | dist = math.sqrt((xr-yr)**2 + (xg-yg)**2 + (xb-yb)**2) 45 | f = lambda x, y: int((x + y)/2 + 0.5) 46 | return (dist, [f(xr, yr), f(xg, yg), f(xb, yb)], "{} - {}: {}".format(x_name, y_name, int(dist + 0.5))) 47 | 48 | def mix(i, j): 49 | return distance(colors[i], colors[j]) 50 | 51 | def dump_col(col): 52 | (r, g, b), name = col 53 | print("{} {} {} {}".format(r, g, b, name)) 54 | 55 | def dump_mix(mix): 56 | dist, (r, g, b), name = mix 57 | print("{} {} {} {}".format(r, g, b, name)) 58 | 59 | # calculate all possible color mixes 60 | mixes = [] 61 | 62 | #for i in range(0, 15): 63 | #for j in range(i + 1, 16): 64 | #mixes.append(distance(colors[i], colors[j])) 65 | 66 | # see http://unusedino.de/ec64/technical/misc/vic656x/colors/ 67 | mixes.append(mix(0x2, 0x6)) 68 | mixes.append(mix(0x2, 0x9)) 69 | mixes.append(mix(0x2, 0xb)) 70 | mixes.append(mix(0x6, 0x9)) 71 | mixes.append(mix(0x6, 0xb)) 72 | mixes.append(mix(0x9, 0xb)) 73 | 74 | mixes.append(mix(0x4, 0x5)) 75 | mixes.append(mix(0x4, 0x8)) 76 | mixes.append(mix(0x4, 0xa)) 77 | mixes.append(mix(0x4, 0xc)) 78 | mixes.append(mix(0x4, 0xe)) 79 | mixes.append(mix(0x5, 0x8)) 80 | mixes.append(mix(0x5, 0xa)) 81 | mixes.append(mix(0x5, 0xc)) 82 | mixes.append(mix(0x5, 0xe)) 83 | mixes.append(mix(0x8, 0xa)) 84 | mixes.append(mix(0x8, 0xc)) 85 | mixes.append(mix(0x8, 0xe)) 86 | mixes.append(mix(0xa, 0xc)) 87 | mixes.append(mix(0xa, 0xe)) 88 | mixes.append(mix(0xc, 0xe)) 89 | 90 | mixes.append(mix(0x3, 0x7)) 91 | mixes.append(mix(0x3, 0xd)) 92 | mixes.append(mix(0x3, 0xf)) 93 | mixes.append(mix(0x7, 0xd)) 94 | mixes.append(mix(0x7, 0xf)) 95 | mixes.append(mix(0xd, 0xf)) 96 | 97 | #mixes.sort(key=lambda dist: dist[0]) 98 | 99 | print("GIMP Palette") 100 | print("Name: C64 Palette") 101 | print("Columns: 16") 102 | 103 | for col in colors: 104 | dump_col(col) 105 | 106 | for m in mixes: 107 | dump_mix(m) 108 | --------------------------------------------------------------------------------