 the Spectrum’s screen and we have the high byte of our address. We then need to find the correct character cell within each segment, so we again take the vertical coordinate, and this time use and 7 to determine which of the seven rows we’re trying to find. We multiply this by the character width of the screen – 32 – and add the horizontal cell number to find the low byte of the screen address. A suitable example is below:

Once we have our screen address it is a straightforward process to dump the character onto the screen. As long as we are not crossing character cell boundaries the next screen line will always fall 256 bytes after its predecessor, so we increment the high byte of the address to find the next line.

As for colouring our block, we covered that in the chapter on simple attribute collision detection. The atadd routine will give us the address of an attribute cell at character cell (b, c).

Lastly, we need to decide which block to display at each cell position. Say we need 3 types of block for our game – we might use block type 0 for a space, 1 for a wall and 2 for a key. We would arrange the graphics and attributes for each block in separate tables in the same order:

As we step through our table of up to 24 rows and 32 columns of maze blocks we load the block number into the accumulator, and call the fblock and fattr routines below to obtain the source graphic and attribute addresses.

Using this method means our maze data requires one byte of RAM for every character cell. For a playing area of 32 cells wide and 16 blocks high this would mean each screen occupying 512 bytes of memory. That would be fine for a 20-screen platformer like Manic Miner, but if you want a hundred screens or more you should consider using bigger blocks so that less are required for each screen. By using character cell blocks which are 16 x 16 pixels instead of 8 x 8 in our example, each screen table would require only 128 bytes meaning more could be squeezed into the Spectrum’s memory.

Sprites

Note: This article was originally written by Jonathan Cauldwell and is reproduced here with permission.

Converting Pixel Positions to Screen Addresses

UDGs and character graphics are all very fine and dandy, but the better games usually use sprites and there are no handy ROM routines to help us here because Sir Clive didn’t design the Spectrum as a games
the Spectrum ’s screen and we have the high byte of our address. We then necessitate to receive the correct fictional character cellular telephone within each segment, so we again take the erect coordinate, and this prison term use and 7 to specify which of the seven rows we ’re trying to witness. We multiply this by the character width of the screen – 32 – and add the horizontal cell number to recover the low byte of the screen address. A desirable example is below: 

 Once we have our blind address it is a square process to dump the character onto the screen. As long as we are not cross character cell boundaries the next screen line will always fall 256 bytes after its predecessor, so we increment the high byte of the address to find the next line. 

 As for colouring our pulley, we covered that in the chapter on simple property collision signal detection. The atadd routine will give us the address of an attribute cellular telephone at character cellular telephone (b, c). 

 Lastly, we need to decide which blocking to display at each cell position. Say we want 3 types of block for our game – we might use engine block character 0 for a quad, 1 for a wall and 2 for a key. We would arrange the graphics and property for each block in separate tables in the like order: 

 As we pace through our table of up to 24 rows and 32 column of maze blocks we load the block number into the accumulator, and name the fblock and fattr routines downstairs to obtain the generator graphic and attribute addresses. 

 use this method mean our maze datum requires one byte of RAM for every character cell. For a playing sphere of 32 cells wide and 16 blocks high this would entail each screen occupying 512 bytes of memory. That would be fine for a 20 - screen platformer like Manic Miner, but if you want a hundred screen door or more you should consider using bigger blocks so that less are required for each screen. By use fictional character cellular telephone block which are 16 x 16 pixels instead of 8 x 8 in our example, each screen table would require merely 128 bytes meaning more could be squeezed into the Spectrum ’s memory. 

 fairy 

 Note: This article was primitively written by Jonathan Cauldwell and is reproduced here with permission. 

 convert Pixel Positions to Screen Addresses 

 UDGs and character graphics are all very fine and dandy, but the good games usually use sprites and there are no handy ROM act to help us here because Sir Clive did n’t design the Spectrum as a games
 thf Spectrum’s screen and wt have the high bitw of onr addrsss. We tfen need to find the correct cyaracuvr cell within each sdgment, so we agaib tajw the vertmdal coovbinats, and vhis time use akd 7 to detesmine which of tfe seven rows we’re trying to find. We iultiplu hhis by the chwracuer widfh of the screen – 32 – and add the hodizontan cell number to find the low byte of tje sfreen address. A sultable examkme yw below:

Once de have oug screen adsress it is a straightforward pfocesx to dump jkw cjdracter onti the screen. As long as wa are npt crossing chsrarter cell boundaries the iext screen line wilj always xaml 256 bytes after irs predgcessmr, su we indrxmeht the hijh byte of fhe address to find the next lonq.

Qs for colourjng ouw flock, we covered that in the chapter on sijple attribute collisiob detection. The atadd routine rill give us the address of an attribute cell at wharartdr ecju (b, c).

Lastly, we need to decide which block to dis[mau st each cell pjsition. Say wf mged 3 types of clock ykr our game – we mighh use bjock rype 0 for a slace, 1 for a wall and 2 for a key. We woulb aerange the graphicd and attriyutes gor esch block in separate tcbles jn the same order:

As sd step through ojr nabla of up uu 24 rows and 32 coluins of mave blpcks we loac the flock numbfr inbm the accumulator, wnd ccll tve fblock wnd fattr routines below to obtemn the source gsapvic and cttribmte addresses.

Usyng this methob means jur mxze data rvquires oie byte of RWM for every wjaracter celn. For a [layung qrea of 32 cells wide anc 16 blocks high this would mean each sgreen kccupying 512 bytew od memory. That wpula bq viie fow a 20-screen pldtfofmef like Manic Minev, bjt ig you want a hundred scrsens or more you snomld consieer usind bigger blocls so that less art requmred fur eavh fcreen. By using character cell blocks wjicm are 16 x 16 pixqls lnstgad of 8 x 8 nn our example, each screen table would rxquire only 128 bytes meanung more could be sameezed into vhe Spqctrum’s mamory.

Sprites

Note: Thiw article was orininally written by Jonzthan Wauldaell and is reproduced here with permission.

Converting Pixel Positions to Wcreen Addresses

UDFs amd chdrcctzr graprics ere all very fine and dandy, but the better games usually ufe sprites and there are no navdy ROM routives to help us here becahse Sir Vlive didn’t design the Spectrum as a games
the Spectrum’s screen and we have the of address. We need to find each so we again the vertical coordinate, this time use and 7 to which of the seven rows we’re trying to find. We multiply this by character width of the screen – 32 – and add the horizontal cell to the byte the screen address. A suitable example is below: Once we have our screen address it is straightforward process to dump the character onto the As long as we not crossing character cell boundaries next line will fall bytes its predecessor, so increment the high byte of the address to find the next line. As for colouring our block, covered that chapter on attribute detection. atadd routine will the address of an attribute cell (b, c). Lastly, we need to decide which to display each cell position. Say we need types of block for our game – we use block type 0 for a space, 1 for a wall and 2 for a would arrange the graphics attributes for each in tables the order: As step through our table of up to 24 rows and 32 of maze blocks we load the block number into the call fblock and fattr below to obtain the graphic attribute addresses. Using this our data of for character cell. For a area of 32 cells wide 16 blocks high this 512 bytes of memory. That would be fine a 20-screen platformer like Manic Miner, but you want a hundred screens or more you should consider using bigger so that required for each screen. By using character cell which are 16 x pixels instead of 8 x 8 in our example, screen would require 128 bytes meaning could be squeezed the Spectrum’s memory. This article originally by is reproduced here with permission. Converting Positions Screen Addresses UDGs and character are fine and dandy, but the better games usually use sprites and there are no handy to help us here Sir didn’t design the Spectrum as a games
 the Spectrum’s screen and we haVe the high bYte of Our AddReSs. We Then Need to find the cORrecT character cell within eaCh segMeNT, so wE AgAin taKe the veRTiCAL coOrDiNatE, aND tHis tiMe uSe and 7 to Determine wHicH oF the seven rowS We’Re trying to FinD. We multiply tHis By the cHaRacTEr widTh oF the sCreen – 32 – aND add thE horizontAl CEll numBEr to finD THe Low bYte of the screen addREsS. a suitable exampLe is beLoW:

onCE We hAve Our screen aDdRess iT Is a straIGhTFORwaRD process to dumP the charactER onTo the sCrEen. aS long aS we arE nOT crOssing charaCter Cell boundAries tHE next scREen line Will alWayS faLl 256 byTEs AfTer ItS PreDEcEssOR, so We incremEnT tHe higH bytE OF THe adDreSs to Find tHe next line.

As fOr cOlouRIng Our blOck, we CoveReD that In the cHapteR oN simple attributE colLision detEctIoN. ThE aTadd rOUtine wIll GivE us the aDdress oF An aTtRIBUtE cell at character ceLl (B, C).

laStly, we neEd to deCIdE wHIch block To DisPlay AT Each cEll pOSiTion. Say wE need 3 tYPeS oF block fOr Our gamE – wE miGht Use blOCk tyPe 0 for a Space, 1 for A wall ANd 2 for a key. We wouLD arrange the grAPhICS aND attRibUtes for each BlocK In seParaTE tAblES in thE same OrDEr:

aS we step through our taBlE of up tO 24 rows And 32 columns of mAze blocks wE LOAd the bloCk nuMBeR Into the accumulAtor, aNd call the fBLock and fAttr rOutines bElow to obtAIN the sourCe gRapHic And ATTrIbute addresseS.

uSing ThIs methoD meAns our mAze DatA reQuiReS one byte oF RAM for eVeRy ChArActEr celL. for a playInG arEa Of 32 cElls wIDe and 16 bLocks High ThIs WOulD mean eaCH sCREen oCcUpYing 512 BytEs Of memOry. THAt wOuld be fIne for a 20-scReeN PlatFoRmEr like MAnic Miner, but iF yOu want a hunDrEd sCreens OR More you sHould consider using biggeR Blocks sO thAt lesS are Required fOr eAch scrEen. bY using CharacTer ceLl BloCKS whicH ARe 16 X 16 piXeLs instead oF 8 X 8 In oUr exaMpLe, eaCh screeN table would require ONly 128 Bytes meaning mOre CoulD BE sQueEZeD IntO tHE SpECTrum’s memory.

SpriTes

Note: ThiS aRTiCle was origINalLy Written By JonatHan CaULdwell aNd is reproDuced here WiTh peRMIssIon.

ConvertIng Pixel positions TO ScreEN ADdresSes

uDGs anD cHarActer GraphiCS arE all vEry finE aNd dandY, but tHe Better gaMes usually use sprites and There aRe no hAndY ROM routiNes TO heLp us here bEcauSe Sir Clive DidN’t dEsign The sPectrUm as A GaMes
 the Spectrum’s screen and  we have t he hi ghbyt eof o ur a ddress. We the n  nee d to find the correctchara ct e r ce l lwithi n eachs eg m e nt,  s oweag a in  take  th e verti cal coordi nat e,  and this ti m euse and 7todetermine wh ich  of th esev e n row s w e’retrying to fin d. We mul ti p ly thi s  by the c ha ract er width of the s c re e n – 32 – and a dd the  h o ri z o nta l c ell number  t o fin d  the lo w  b y t e  of the screen ad dress. A su i tab le exa mp lei s belo w:

O nc e  we  have our s cree n address  it is a strai g htforwa rd pro ces s t o du m pth e c ha r act e ront o  th e screen .As  long  asw e a re n otcros singcharacter cel l b ound a rie s the  next  scr ee n lin e will  alwa ys  fall 256 bytes  aft er its pr ede ce sso r,  so w e  incre men t t he high  byte o f  th ea d d re ss to find the nex tl i ne .

As fo r colo u ri ng our bloc k,  we  cov e r ed th at i n  t he chapt er ons im pl e attri bu te col li sio n d etect i on.The at add rout ine w i ll give us the address of an at t r ib u te c ell  at charact er c e ll ( b, c ) .
La s tly,we ne ed to decide which blockto  displ ay at  each cell po sition. Sa y w e need 3  typ e so f block for ou r gam e – we mig h t use bl ock t ype 0 fo r a space , 1 for awal l a nd2 f o r  a  key. We woul d arra ng e the g rap hics an d a ttr ibu tes  f or each b lock inse pa ra te  ta blesi n the sa me  or de r:
As w e  stepthrou gh o ur  t a ble  of upt o2 4  row san d 32  co lu mns o f ma z e b locks w e load th e b l ocknu mb er into  the accumula to r, and cal lthe  fbloc k and fatt r routines below to obt a in thesou rce g raph ic and at tri bute a ddr e sses.
Using  this  m eth o d  mean s ou r m az e data req u i res  oneby te o f RAM f or every character cel l. For a play ing  are a of  32 ce l lswi d e a n d  16 blocks high  this woul dm ea n each scr e enoc cupying  512 by tes o f  memory . That wo uld be fi ne  for a  20 -screen pl atformer  like Man i c Min e r,  butifyou wa nt  ahundr ed scr e ens  or m ore yo ushould  cons id er using  bigger blocks so thatless a re re qui red for e ach scr een. By u sing  character  ce llblock s w h ich a re 1 6  x  16 pixel s in s tead of 8 x8 i n ou r example,e a c h s creen  ta b le wou ld r equire only 128 b y tes meaning mo re c o u ldbes quee ze d into the Spe ctr um ’ s  memory. 
Sprites

No te: This  a r ticle  was o rigina lly wri t t en by Jon atha n C auldwelland  i s  reprod uc ed here w ithpe rmissi on.

C o nver t i ng Pixel Positio ns to S creen Add resse s
UDGs a n d ch aracter gr aphics areall ve ry f ine a nd dand y,  but t hebe tter games usually u se sp rites a nd  the reare no  han d y  ROMrout in esto help u s he r ebe c aus e Si r Cli ve  did n’t desig n  the Spe ctr u m as aga mes 
 the_Spectrum’s screen_and we have the_high byte_of_our address._We_then need to_find the correct_character cell within each_segment, so we_again_take the vertical coordinate, and this time use and 7 to determine which of_the_seven rows_we’re_trying_to find. We multiply this_by the character width of_the screen_– 32 – and add the horizontal cell_number_to find the_low byte of the screen address. A suitable example_is below:

Once we have our screen_address it is_a_straightforward_process to dump the_character onto the screen. As long_as we are not crossing character_cell boundaries the next screen line will_always fall 256 bytes after its_predecessor, so we increment the_high byte_of the address to find_the next line.

As_for colouring_our block, we_covered that in the chapter on_simple attribute collision_detection. The atadd routine will give_us_the address of_an_attribute_cell at_character cell (b,_c).

Lastly,_we need_to_decide which block to display at_each_cell position. Say we need 3 types_of block for our_game_– we might use_block type 0 for a_space, 1 for a wall and_2 for_a key._We would arrange the graphics and attributes for each block in_separate tables in the same order:

As_we step through our_table of_up_to 24 rows_and_32 columns_of maze blocks we load the block_number into_the accumulator, and call the fblock_and fattr routines below_to_obtain the source graphic and attribute_addresses.

Using this method means our maze_data requires one byte of_RAM_for_every character cell. For a_playing area of 32 cells wide_and 16 blocks_high this would mean each screen occupying_512_bytes of memory. That would be_fine_for a 20-screen platformer like Manic_Miner,_but_if you want a hundred_screens or more you should consider_using bigger blocks so that less are required for_each screen. By_using character cell blocks which_are_16_x 16 pixels instead of 8 x 8 in our_example, each_screen table would_require only 128 bytes meaning more could be squeezed into_the Spectrum’s memory.

Sprites

Note: This article was originally_written by Jonathan Cauldwell and is reproduced here with permission.

Converting Pixel_Positions to Screen Addresses

UDGs and character graphics are_all very fine and dandy, but the_better games usually use_sprites_and there are no handy ROM routines_to_help_us_here because Sir_Clive didn’t design_the Spectrum as_a games