{"id":356,"date":"2025-05-17T16:39:54","date_gmt":"2025-05-17T06:39:54","guid":{"rendered":"http:\/\/electricadventures.net\/?p=356"},"modified":"2025-05-17T16:39:54","modified_gmt":"2025-05-17T06:39:54","slug":"beyond-basic-part-1","status":"publish","type":"post","link":"https:\/\/electricadventures.net\/?p=356","title":{"rendered":"Beyond Basic &#8211; Part 1"},"content":{"rendered":"\n<p><strong>Written By:<\/strong>&nbsp;Tony Cruise<\/p>\n\n\n\n<p><strong>First Published:<\/strong>&nbsp;MSX and Spectravideo Computer Forum Vol. 2 No. 10<\/p>\n\n\n\n<h1 class=\"wp-block-heading\">Introduction<\/h1>\n\n\n\n<p>In this series of articles, I aim to provide an insight into machine code programming on your computer.\u00a0\u00a0The articles will take for granted that you know how to program in BASIC, but will not require knowledge of machine code.\u00a0\u00a0Full machine code listings will be included for the person wanting to know more, but they will not be necessary to understand the article.<\/p>\n\n\n\n<p>The series of programs will eventually add extra commands that you can use in your BASIC programs.<\/p>\n\n\n\n<p>The sections will include:-<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Making use of all 64k of your computer\u2019s memory<\/li>\n\n\n\n<li>Printer dump routines<\/li>\n\n\n\n<li>Screen save and load to memory and\/or tape and disk<\/li>\n\n\n\n<li>Automatic sprite movement with velocities<\/li>\n\n\n\n<li>Sprite collision detection<\/li>\n\n\n\n<li>Screen scrolling routines<\/li>\n<\/ul>\n\n\n\n<h1 class=\"wp-block-heading\">Part 1 \u2013 Using More Memory<\/h1>\n\n\n\n<p>A lot of the original MSX game titles that used more than 32K of RAM were very machine dependant.&nbsp;&nbsp;A classic example is \u201cFinders Keepers\u201d which only works on the Sony HIT-BIT.&nbsp;&nbsp;The author took it for granted that all of the MSX machines would have their RAM in the same area.&nbsp;&nbsp;To explain this further look at the diagram below:<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><tbody><tr><td>0000H<\/td><td>Slot 0<\/td><td>Slot 1<\/td><td>Slot 2<\/td><td>Slot 3<\/td><td>&nbsp;<\/td><\/tr><tr><td>&nbsp;<\/td><td>ROM<\/td><td>&nbsp;<\/td><td>SONYRAM<\/td><td>&nbsp;<\/td><td>Page 0<\/td><\/tr><tr><td>4000H<\/td><td>&nbsp;<\/td><td>&nbsp;<\/td><td>&nbsp;<\/td><td>&nbsp;<\/td><td>&nbsp;<\/td><\/tr><tr><td>&nbsp;<\/td><td>ROM<\/td><td>&nbsp;<\/td><td>SONYRAM<\/td><td>&nbsp;<\/td><td>Page 1<\/td><\/tr><tr><td>8000H<\/td><td>&nbsp;<\/td><td>&nbsp;<\/td><td>&nbsp;<\/td><td>&nbsp;<\/td><td>&nbsp;<\/td><\/tr><tr><td>&nbsp;<\/td><td>ROM<\/td><td>&nbsp;<\/td><td>SONYRAM<\/td><td>&nbsp;<\/td><td>Page 2<\/td><\/tr><tr><td>C000H<\/td><td>&nbsp;<\/td><td>&nbsp;<\/td><td>&nbsp;<\/td><td>&nbsp;<\/td><td>&nbsp;<\/td><\/tr><tr><td>&nbsp;<\/td><td>ROM<\/td><td>&nbsp;<\/td><td>SONYRAM<\/td><td>&nbsp;<\/td><td>Page 3<\/td><\/tr><tr><td>FFFFH<\/td><td>&nbsp;<\/td><td>&nbsp;<\/td><td>&nbsp;<\/td><td>&nbsp;<\/td><td>&nbsp;<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>&nbsp;Any of the boxes in the picture can hold 16K of RAM or ROM&nbsp;&nbsp;(Up to 64K can be placed in each box, but that is beyond the scope of this article).&nbsp;&nbsp;Only one of the four slots can be activated for each page of memory.&nbsp;&nbsp;Thus when you turn on the computer the BASIC ROM is activated, so only the top 32K of RAM can be accessed.&nbsp;&nbsp;This is why you only get 28K of RAM free for your BASIC programs (The other 4K of RAM is used by BASIC as a storage space for system variables e.g. cursor position).<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Machine Code Program<\/h2>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><tbody><tr><td>&nbsp;<\/td><td>1 ORIGIN<\/td><td>ORG 08400H<\/td><td>&nbsp;<\/td><\/tr><tr><td>&nbsp;<\/td><td>2 ;<\/td><td>&nbsp;<\/td><td>&nbsp;<\/td><\/tr><tr><td>&nbsp;<\/td><td>3 ; PROGRAM TO FIND EXTRA RAM IN MSX COMPUTERS<\/td><td><\/td><td><\/td><\/tr><tr><td>&nbsp;<\/td><td>4 ;<\/td><td>&nbsp;<\/td><td>&nbsp;<\/td><\/tr><tr><td>F3<\/td><td>5 START<\/td><td>DI<\/td><td>; Disables all interrupts<\/td><\/tr><tr><td>DBA8<\/td><td>6<\/td><td>IN A,(0A8H)<\/td><td>; Get page settings<\/td><\/tr><tr><td>4F<\/td><td>7<\/td><td>LD C,A<\/td><td>; Store in C<\/td><\/tr><tr><td>0603<\/td><td>8<\/td><td>LD B,3<\/td><td>; Loop counter<\/td><\/tr><tr><td>210000<\/td><td>9<\/td><td>LD HL,0<\/td><td>; Memory location to test<\/td><\/tr><tr><td>C5<\/td><td>10 LP1<\/td><td>PUSH BC<\/td><td>; Save BC<\/td><\/tr><tr><td>79<\/td><td>11<\/td><td>LD A,C<\/td><td>;<\/td><\/tr><tr><td>B0<\/td><td>12<\/td><td>OR B<\/td><td>;<\/td><\/tr><tr><td>CB20<\/td><td>13<\/td><td>SLA B<\/td><td>;<\/td><\/tr><tr><td>CB20<\/td><td>14<\/td><td>SLA B<\/td><td>;<\/td><\/tr><tr><td>B0<\/td><td>15<\/td><td>OR B<\/td><td>; Calculate slot<\/td><\/tr><tr><td>D3AB<\/td><td>16<\/td><td>OUT (0A8H),A<\/td><td>; Send bank information<\/td><\/tr><tr><td>C1<\/td><td>17<\/td><td>POP BC<\/td><td>; Restore BC<\/td><\/tr><tr><td>3E01<\/td><td>18<\/td><td>LD A,1<\/td><td>;<\/td><\/tr><tr><td>77<\/td><td>19<\/td><td>LD (HL),A<\/td><td>;<\/td><\/tr><tr><td>7E<\/td><td>20<\/td><td>LD A,(HL)<\/td><td>;<\/td><\/tr><tr><td>3D<\/td><td>21<\/td><td>DEC A<\/td><td>;<\/td><\/tr><tr><td>2802<\/td><td>22<\/td><td>JR Z,EXIT<\/td><td>; Is it RAM<\/td><\/tr><tr><td>10EC<\/td><td>23<\/td><td>DJNZ LP1<\/td><td>; Do loop again<\/td><\/tr><tr><td>78<\/td><td>24 EXIT<\/td><td>LD A,B<\/td><td>;<\/td><\/tr><tr><td>B1<\/td><td>25<\/td><td>OR C<\/td><td>;<\/td><\/tr><tr><td>CB20<\/td><td>26<\/td><td>SLA B<\/td><td>;<\/td><\/tr><tr><td>CB20<\/td><td>27<\/td><td>SLA B<\/td><td>;<\/td><\/tr><tr><td>B0<\/td><td>28<\/td><td>OR B<\/td><td>; Calculate slot<\/td><\/tr><tr><td>32E7FF<\/td><td>29<\/td><td>LD (0FFE7H),A<\/td><td>; Store in 0FFE7H<\/td><\/tr><tr><td>79<\/td><td>30<\/td><td>LD A,C<\/td><td>; Set pages to normal<\/td><\/tr><tr><td>D3AB<\/td><td>31<\/td><td>OUT (0A8H),A<\/td><td>;<\/td><\/tr><tr><td>FB<\/td><td>32<\/td><td>EI<\/td><td>; Enable interrupts<\/td><\/tr><tr><td>C(<\/td><td>33<\/td><td>RET<\/td><td>; Return to BASIC<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Basic Loader<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>10 CLS:CLEAR 200,&amp;HCFFF:DEFINTA-Z:A=&amp;HD000\n20 READ A$:IF A$ &lt;> \u201c@\u201d THEN POKE A, VAL(\u201c&amp;H\u201d+A$):A=A+1:GOTO 20\n30 PRINT\u201d\u00a0\u00a0INSERT TAPE\/DISK TO SAVE PROGRAM\u201d\n40 PRINT\u201d\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0AND PRESS ANY KEY\u201d\n50 A$=INPUT$(1):PRINT:PRINT \u201c\u00a0\u00a0SAVING ....\u201d\n60 BSAVE\u201dCAS:RAMSEL\u201d,&amp;HD000,A-1:REM Remove CAS: if using disk\n100 DATA F3,DB,A8,4F,06,03,21,00,00,C5\n110 DATA 79,B0,CB,20,CB,20,B0,D3,A8,C1\n120 DATA 3E,01,77,7E,3D,28,02,10,EC,78\n130 DATA B1,CB,20,CB,20,B0,32,E7,FF,79\n140 DATA D3,A8,FB,C9\n150 DATA @<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Written By:&nbsp;Tony Cruise First Published:&nbsp;MSX and Spectravideo Computer Forum Vol. 2 No. 10 Introduction In this series of articles, I aim to provide an insight into machine code programming on your computer.\u00a0\u00a0The articles will take for granted that you know how to program in BASIC, but will not require knowledge of machine code.\u00a0\u00a0Full machine code<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[61],"tags":[],"class_list":["post-356","post","type-post","status-publish","format-standard","hentry","category-beyond-basic"],"acf":[],"_links":{"self":[{"href":"https:\/\/electricadventures.net\/index.php?rest_route=\/wp\/v2\/posts\/356","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/electricadventures.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/electricadventures.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/electricadventures.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/electricadventures.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=356"}],"version-history":[{"count":1,"href":"https:\/\/electricadventures.net\/index.php?rest_route=\/wp\/v2\/posts\/356\/revisions"}],"predecessor-version":[{"id":357,"href":"https:\/\/electricadventures.net\/index.php?rest_route=\/wp\/v2\/posts\/356\/revisions\/357"}],"wp:attachment":[{"href":"https:\/\/electricadventures.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=356"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/electricadventures.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=356"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/electricadventures.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=356"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}