├── closerun.bin.68k ├── addchip.bootblock.bin.68k ├── README.md ├── closerun.s ├── addchip.bootblock.s └── LICENSE /closerun.bin.68k: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/earok/close-and-run-amiga68k/HEAD/closerun.bin.68k -------------------------------------------------------------------------------- /addchip.bootblock.bin.68k: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/earok/close-and-run-amiga68k/HEAD/addchip.bootblock.bin.68k -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # close-and-run-amiga68k 2 | Tools for maximizing chip ram when loading Amiga games or applications from floppy on Kickstart 1.3 3 | 4 | ## The problem... 5 | When booting a floppy disk on Amiga Kickstart 1.3, you lose more than 40KB of chipram that could otherwise be used for a game or other application. This is because the CLI will always open before the startup-sequence is triggered. From Kickstart 2.0 onward, this isn't a problem - the CLI will only open when requested. 6 | 7 | ## The solution 8 | One solution is of course, to write your game to be entirely system-unfriendly and boot from an NDOS disk. 9 | 10 | If that isn't a possibility - for example if you're developing in standard Blitz Basic - the code and binaries in this repository may be of some interest. 11 | 12 | ### AddChip bootblock 13 | The AddChip bootblock features a variety of tricks to claw back memory - for example, unloading the memory used by external drives DF1-DF3. You can use this to create your boot disk. Using the bootblock will also ensure that the CloseRun utility will work correctly on all KickStarts. 14 | 15 | ### CloseRun 16 | When used like this: 17 | 18 | `closerun the "quick" brown "fox` 19 | 20 | CloseRun will load the "quick" and "fox" executables in succession, ignoring text outside of quotes - so it can be used for creative startup-sequence text. 21 | 22 | ## Other alternatives 23 | As previously mentioned, you may wish to investigate making your game load in an NDOS way. 24 | 25 | Add21K restores some of the lost RAM by trashing the CLI's bitplanes. Though of course, you only get 21KB back this way. 26 | 27 | The "official" Commodore way will regain a similar amount of memory as CloseRun, though not quite as much. You'll need the tool "Endrun" to open your app after the CLI is closed, and you'll need to run CloseWorkbench() inside your app to actually free the memory. 28 | 29 | More information here: http://amigadev.elowar.com/read/ADCD_2.1/AmigaMail_Vol2_guide/node002B.html 30 | 31 | ## Blitz Basic notes 32 | You still need to run CloseWorkbench_() inside of your Blitz code in order to actually free RAM. 33 | 34 | The "WBStartup" command may not be compatible with the AddChip bootblock. 35 | 36 | ## Acknowledgements 37 | All of the code in this repository comes from Ross and originated on the English Amiga Board - eab.abime.net 38 | 39 | -------------------------------------------------------------------------------- /closerun.s: -------------------------------------------------------------------------------- 1 | _LVOOldOpenLibrary equ -$198 2 | _LVOCloseLibrary equ -$19E 3 | _LVOForbid equ -$84 4 | _LVOCreateProc equ -$8A 5 | _LVOLoadSeg equ -150 6 | _LVOUnLoadSeg equ -156 7 | _LVODelay equ -$C6 8 | _LVOCloseWorkBench equ -$4E 9 | _LVOClose equ -$24 10 | _LVOExit equ -$90 11 | cli_StandardInput equ $1C 12 | cli_CurrentInput equ $20 13 | cli_Background equ $2C 14 | fh_Pos equ $10 15 | fh_End equ $14 16 | pr_CLI equ $AC 17 | ThisTask equ $114 18 | **************************************************************************** 19 | 20 | SECTION Close_Run,CODE 21 | 22 | start moveq #'"',d1 23 | moveq #0,d2 24 | lea $300.w,a1 25 | move.l a1,d5 26 | lea $1F(a1),a2 27 | .k1 subq.w #1,d0 28 | move.b d2,(a2)+ 29 | .k2 subq.w #1,d0 30 | bmi.b .je 31 | cmp.b (a0)+,d1 32 | bne.b .k2 33 | move.l a2,(a1)+ 34 | .ic move.b (a0)+,d3 35 | cmp.b d3,d1 36 | beq.b .k1 37 | move.b d3,(a2)+ 38 | subq.w #1,d0 39 | bpl.b .ic 40 | subq.l #4,a1 41 | .je move.l d2,(a1)+ 42 | 43 | lea (a1),a2 44 | movea.l (4).w,a6 45 | move.l 156(a6),a0 ;gfxbase 46 | moveq #-2,d0 47 | move.l #$01800000,(a2)+ 48 | move.l #$01000200,(a2)+ 49 | move.l d0,(a2) 50 | move.l a1,50(a0) ;LOFlist 51 | 52 | movea.l ThisTask(a6),a2 53 | lea (a6),a4 54 | lea (int.lib,pc),a1 55 | jsr (_LVOOldOpenLibrary,a6) 56 | movea.l d0,a5 57 | lea (dos.lib,pc),a1 58 | jsr (_LVOOldOpenLibrary,a6) 59 | movea.l d0,a6 60 | moveq #$10,d4 61 | lsl.w #8,d4 62 | lea start-4(pc),a0 63 | move.l (a0),d3 64 | ; moveq #0,d2 65 | move.l d2,(a0) 66 | moveq #(heap-close_run-8+4+3)>>2,d1 67 | add.l d3,d1 68 | lsl.l #2,d1 69 | move.l d1,a3 70 | movem.l d3/d5/a4-a6,-(a3) 71 | jsr (_LVOCreateProc,a6) 72 | move.l (pr_CLI,a2),a2 73 | adda.l a2,a2 74 | lea (cli_StandardInput,a2,a2.l),a2 75 | move.l (a2)+,d3 ;d3=sfh=mycli->cli_StandardInput; 76 | move.l (a2),d1 ;d1=cfh=mycli->cli_CurrentInput; 77 | movea.l d3,a0 78 | adda.l a0,a0 ;a0=mfh=BADDR(sfh); 79 | lea (fh_End,a0,a0.l),a0 80 | move.l (a0),-4(a0) ;mfh->fh_Pos=mfh->fh_End; 81 | move.l d2,(a0) ;mfh->fh_End=0; 82 | cmp.l d3,d1 ;if(sfh!=cfh) 83 | beq.b .dp 84 | move.l d3,(a2) ;mycli->cli_CurrentInput=sfh; 85 | jsr (_LVOClose,a6) ;Close(cfh); 86 | .dp moveq #-1,d0 ;mycli->cli_Background=-1; 87 | move.l d0,(cli_Background-cli_CurrentInput,a2) 88 | moveq #0,d1 ;Exit(0); 89 | jmp (_LVOExit,a6) 90 | ; rts 91 | 92 | dos.lib dc.b 'dos.library',0 93 | int.lib dc.b 'intuition.library',0 94 | 95 | 96 | SECTION Close_Run_detach,CODE 97 | 98 | close_run 99 | movem.l (heap-8-5*4,pc),d2/a2-a5 100 | 101 | .ll lea (a5),a6 102 | moveq #5,d1 103 | jsr (_LVODelay,a6) 104 | lea (a4),a6 105 | jsr (_LVOCloseWorkBench,a6) 106 | tst.l d0 107 | beq.b .ll 108 | lea (a5),a6 109 | 110 | .lo move.l (a2)+,d1 111 | beq.b .dd 112 | jsr (_LVOLoadSeg,a6) 113 | move.l d0,d1 114 | beq.b .lo 115 | movem.l d1-d2/a2-a6,-(sp) 116 | add.l d0,d0 117 | movea.l d0,a0 118 | jsr (4,a0,d0.l) ;run 119 | movem.l (sp)+,d1-d2/a2-a6 120 | jsr (_LVOUnLoadSeg,a6) 121 | bra.b .lo 122 | 123 | .dd lea (a3),a6 124 | jsr (_LVOForbid,a6) 125 | move.l d2,d1 126 | lea (a5),a6 127 | jsr (_LVOUnLoadSeg,a6) 128 | lea (a3),a6 129 | lea (a4),a1 130 | jsr (_LVOCloseLibrary,a6) 131 | lea (a5),a1 132 | jsr (_LVOCloseLibrary,a6) 133 | moveq #0,d0 134 | rts 135 | 136 | ; cnop 0,4 137 | ; 0, 12345678901234567890123456789012345678 9 138 | dc.b 0,'$VER: Close&Run 1.1 (2.5.2019) by ross',0 139 | ; cnop 0,4 140 | heap 141 | 142 | end 143 | -------------------------------------------------------------------------------- /addchip.bootblock.s: -------------------------------------------------------------------------------- 1 | 2 | incdir Include3.1: 3 | include LVOs.i 4 | 5 | Height EQU 50 6 | zeropage EQU $100 7 | 8 | RT_INIT EQU $16 9 | lib_Version EQU $14 10 | LibList EQU $17a 11 | io_Device EQU $14 12 | KS20 EQU 36 13 | 14 | 15 | boot dc.b 'DOS',0 16 | dc.b 'r05s' ;tagged 17 | dc.l 880 18 | 19 | start movem.l d2-d5/a2/a5,-(a7) 20 | 21 | moveq #-1,d0 ;disable externals drives 22 | movea.l io_Device(a1),a1 23 | movea.l $3c(a1),a1 ;the 'old times mod' 24 | lea $34(a1),a1 25 | move.l d0,(a1)+ ;df1: 26 | move.l d0,(a1)+ ;df2: 27 | move.l d0,(a1) ;and why not.. df3: 28 | 29 | moveq #0,d4 30 | cmpi.w #KS20,lib_Version(a6) ;fork 31 | shs d4 32 | 33 | lea zeropage.w,a5 ;a0jmp 34 | move.l a5,d5 35 | lea a0jmp(pc),a0 36 | moveq #(endscreen-a0jmp)/4-1,d0 37 | _l move.l (a0)+,(a5)+ 38 | dbf d0,_l ;at end a5=zerobss 39 | 40 | movea.l LibList(a6),a0 41 | lea intuitionlib(pc),a1 42 | jsr _LVOFindName(a6) 43 | move.l d0,(a5)+ ;intuitionbase 44 | beq.b _exit 45 | 46 | lea intuitionlib(pc),a1 47 | jsr _LVOFindResident(a6) 48 | tst.l d0 ;can be omitted.. 49 | beq.b _exit 50 | 51 | lea wbname(pc),a1 ;'Workbench Screen',0 52 | moveq #doslib-wbname,d1 ;strlen 53 | bsr.b findstrres 54 | move.l a0,title-(zerobss+4)(a5) 55 | 56 | move.l d4,(a5)+ ;v36? 57 | beq.b notags 58 | moveq #10,d1 ;strlen 59 | clr.b -1(a1,d1.w) ;'Workbench',0 60 | bsr.b findstrres 61 | move.l a0,pubname-(zerobss+8)(a5) 62 | 63 | 64 | notags lea doslib(pc),a1 65 | jsr _LVOFindResident(a6) 66 | tst.l d0 67 | beq.b _exit 68 | movea.l d0,a1 69 | move.l RT_INIT(a1),(a5) ;dosinit 70 | 71 | tst.l d4 ;v36? 72 | beq.b _done 73 | move.w #Height,_h-(zerobss+8)(a5) ;set height for >=v36 74 | jsr _LVOCacheClearU(a6) 75 | 76 | _done moveq #-1,d0 77 | _exit movea.l d5,a0 ;a0jmp 78 | not.l d0 79 | movem.l (sp)+,d2-d5/a2/a5 80 | rts 81 | 82 | 83 | ;input: d0=resident base 84 | ; d1=strlen 85 | ; a1=string to search 86 | ;output: a0=&str 87 | ;used: d2/d3/a2 saved by main, a0 as return code 88 | 89 | findstrres movea.l d0,a0 90 | _search move.w d1,d2 91 | subq.w #2,d2 ;-(dbne,+) 92 | movea.l a1,a2 93 | move.b (a2)+,d3 94 | _s1 cmp.b (a0)+,d3 95 | bne.b _s1 96 | _s2 cmpm.b (a2)+,(a0)+ 97 | dbne d2,_s2 98 | bne.b _search 99 | suba.l d1,a0 100 | rts 101 | 102 | wbname dc.b 'Workbench Screen',0 103 | doslib dc.b 'dos.library',0 104 | intuitionlib dc.b 'intuition.library',0 105 | 106 | fakechecksum dc.l 0 107 | 108 | cnop 0,4 109 | 110 | 111 | a0jmp lea zerobss(pc),a5 112 | movea.l (a5)+,a6 ;intuitionbase 113 | jsr _LVOOpenIntuition(a6) ;KS1.x mandatory (undocumented) 114 | lea wbscreen(pc),a0 115 | tst.l (a5)+ 116 | bne.b v36 117 | jsr _LVOOpenScreen(a6) 118 | bra.s dos 119 | v36 lea tagitems(pc),a1 ;Workbench need to be Pub 120 | jsr _LVOOpenScreenTagList(a6) 121 | dos movea.l (a5),a0 ;dosinit 122 | jmp (a0) ;start amigados 123 | cnop 0,4 124 | 125 | tagitems dc.l $8000002f ;SA_PubName 126 | pubname dc.l 0 ;'Workbench',0 127 | ; dc.l 0 ;TAG_DONE (fixed to wbscreen struct) 128 | ; 129 | wbscreen dc.w 0 ;WORD LeftEdge 130 | dc.w 0 ;WORD TopEdge 131 | dc.w 640 ;WORD Widht 132 | _h dc.w 200 ;WORD Height (KS1.x min height) 133 | dc.w 1 ;WORD Depth 134 | dc.b 0,1 ;UBYTE DetailPen, BlockPen 135 | dc.w $8000 ;UWORD ViewModes -> HIRES 136 | dc.w 1 ;UWORD Type -> WBENCHSCREEN 137 | dc.l 0 ;struct TextAttr *Font, defaults 138 | title dc.l 0 ;UBYTE *DefaultTitle, ROM 139 | dc.l 0 ;struct Gadget *Gadgets, UNUSED 140 | dc.l 0 ;struct BitMap *CustomBitMap, NULL 141 | endscreen ; 142 | ; 143 | zerobss ; ;(fixed to wbscreen struct) 144 | ;intuitionbase ;zerobss+0 145 | ; ds.l 1 146 | ;stag ;zerobss+4 147 | ; ds.l 1 148 | ;dosinit ;zerobss+8 149 | ; ds.l 1 150 | endzero 151 | 152 | cnop 0,16 153 | ver dc.b '$VER: addchip.bootblock 1.1 (27.07.2017) by ross',0 154 | 155 | cnop 0,16 156 | message dc.b ' This code snippet allows you to regain some precious chip ram. ' 157 | cnop 0,16 158 | dc.b '* Greetings to all Evergreen Amiga Board members! *' 159 | even 160 | 161 | END 162 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Creative Commons Legal Code 2 | 3 | CC0 1.0 Universal 4 | 5 | CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE 6 | LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN 7 | ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS 8 | INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES 9 | REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS 10 | PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM 11 | THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED 12 | HEREUNDER. 13 | 14 | Statement of Purpose 15 | 16 | The laws of most jurisdictions throughout the world automatically confer 17 | exclusive Copyright and Related Rights (defined below) upon the creator 18 | and subsequent owner(s) (each and all, an "owner") of an original work of 19 | authorship and/or a database (each, a "Work"). 20 | 21 | Certain owners wish to permanently relinquish those rights to a Work for 22 | the purpose of contributing to a commons of creative, cultural and 23 | scientific works ("Commons") that the public can reliably and without fear 24 | of later claims of infringement build upon, modify, incorporate in other 25 | works, reuse and redistribute as freely as possible in any form whatsoever 26 | and for any purposes, including without limitation commercial purposes. 27 | These owners may contribute to the Commons to promote the ideal of a free 28 | culture and the further production of creative, cultural and scientific 29 | works, or to gain reputation or greater distribution for their Work in 30 | part through the use and efforts of others. 31 | 32 | For these and/or other purposes and motivations, and without any 33 | expectation of additional consideration or compensation, the person 34 | associating CC0 with a Work (the "Affirmer"), to the extent that he or she 35 | is an owner of Copyright and Related Rights in the Work, voluntarily 36 | elects to apply CC0 to the Work and publicly distribute the Work under its 37 | terms, with knowledge of his or her Copyright and Related Rights in the 38 | Work and the meaning and intended legal effect of CC0 on those rights. 39 | 40 | 1. Copyright and Related Rights. A Work made available under CC0 may be 41 | protected by copyright and related or neighboring rights ("Copyright and 42 | Related Rights"). Copyright and Related Rights include, but are not 43 | limited to, the following: 44 | 45 | i. the right to reproduce, adapt, distribute, perform, display, 46 | communicate, and translate a Work; 47 | ii. moral rights retained by the original author(s) and/or performer(s); 48 | iii. publicity and privacy rights pertaining to a person's image or 49 | likeness depicted in a Work; 50 | iv. rights protecting against unfair competition in regards to a Work, 51 | subject to the limitations in paragraph 4(a), below; 52 | v. rights protecting the extraction, dissemination, use and reuse of data 53 | in a Work; 54 | vi. database rights (such as those arising under Directive 96/9/EC of the 55 | European Parliament and of the Council of 11 March 1996 on the legal 56 | protection of databases, and under any national implementation 57 | thereof, including any amended or successor version of such 58 | directive); and 59 | vii. other similar, equivalent or corresponding rights throughout the 60 | world based on applicable law or treaty, and any national 61 | implementations thereof. 62 | 63 | 2. Waiver. To the greatest extent permitted by, but not in contravention 64 | of, applicable law, Affirmer hereby overtly, fully, permanently, 65 | irrevocably and unconditionally waives, abandons, and surrenders all of 66 | Affirmer's Copyright and Related Rights and associated claims and causes 67 | of action, whether now known or unknown (including existing as well as 68 | future claims and causes of action), in the Work (i) in all territories 69 | worldwide, (ii) for the maximum duration provided by applicable law or 70 | treaty (including future time extensions), (iii) in any current or future 71 | medium and for any number of copies, and (iv) for any purpose whatsoever, 72 | including without limitation commercial, advertising or promotional 73 | purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each 74 | member of the public at large and to the detriment of Affirmer's heirs and 75 | successors, fully intending that such Waiver shall not be subject to 76 | revocation, rescission, cancellation, termination, or any other legal or 77 | equitable action to disrupt the quiet enjoyment of the Work by the public 78 | as contemplated by Affirmer's express Statement of Purpose. 79 | 80 | 3. Public License Fallback. Should any part of the Waiver for any reason 81 | be judged legally invalid or ineffective under applicable law, then the 82 | Waiver shall be preserved to the maximum extent permitted taking into 83 | account Affirmer's express Statement of Purpose. In addition, to the 84 | extent the Waiver is so judged Affirmer hereby grants to each affected 85 | person a royalty-free, non transferable, non sublicensable, non exclusive, 86 | irrevocable and unconditional license to exercise Affirmer's Copyright and 87 | Related Rights in the Work (i) in all territories worldwide, (ii) for the 88 | maximum duration provided by applicable law or treaty (including future 89 | time extensions), (iii) in any current or future medium and for any number 90 | of copies, and (iv) for any purpose whatsoever, including without 91 | limitation commercial, advertising or promotional purposes (the 92 | "License"). The License shall be deemed effective as of the date CC0 was 93 | applied by Affirmer to the Work. Should any part of the License for any 94 | reason be judged legally invalid or ineffective under applicable law, such 95 | partial invalidity or ineffectiveness shall not invalidate the remainder 96 | of the License, and in such case Affirmer hereby affirms that he or she 97 | will not (i) exercise any of his or her remaining Copyright and Related 98 | Rights in the Work or (ii) assert any associated claims and causes of 99 | action with respect to the Work, in either case contrary to Affirmer's 100 | express Statement of Purpose. 101 | 102 | 4. Limitations and Disclaimers. 103 | 104 | a. No trademark or patent rights held by Affirmer are waived, abandoned, 105 | surrendered, licensed or otherwise affected by this document. 106 | b. Affirmer offers the Work as-is and makes no representations or 107 | warranties of any kind concerning the Work, express, implied, 108 | statutory or otherwise, including without limitation warranties of 109 | title, merchantability, fitness for a particular purpose, non 110 | infringement, or the absence of latent or other defects, accuracy, or 111 | the present or absence of errors, whether or not discoverable, all to 112 | the greatest extent permissible under applicable law. 113 | c. Affirmer disclaims responsibility for clearing rights of other persons 114 | that may apply to the Work or any use thereof, including without 115 | limitation any person's Copyright and Related Rights in the Work. 116 | Further, Affirmer disclaims responsibility for obtaining any necessary 117 | consents, permissions or other rights required for any use of the 118 | Work. 119 | d. Affirmer understands and acknowledges that Creative Commons is not a 120 | party to this document and has no duty or obligation with respect to 121 | this CC0 or use of the Work. 122 | --------------------------------------------------------------------------------