Author Topic: Help with a little screen test task  (Read 696 times)

0 Members and 1 Guest are viewing this topic.

Offline Kitsune Mifune

  • CPC464
  • **
  • Posts: 36
  • Country: scotland
  • On a retro game making bucket list
  • Liked: 8
  • Likes Given: 6
Help with a little screen test task
« on: 14:06, 24 April 19 »
Hi all.

Really been enjoying delving into the Z80 assembly over the last week, although much of it is still very confusing. I've decided to set myself very small tasks that aren't just copying and pasting bits of code (much) so that I can try and organise what's going on in my head bit by bit in my own way.

My first task was:  Set the screen mode, clear the screen, change the border colour, and then put a pixel on the screen. Nothing more (later I'll try to move the pixel).

I've managed to do all of them but not together. I can either:

- change the screen mode, change the border colour, and set a pixel on the screen (I had to remover the screen clear to do this).

or

- Change the screen mode, change the border colour, and clear the screen (the pixel doesn't show then).

I think I know what's going wrong (in theory) but I'm still doing a lot of "press & guess" with the numbers and how things are organised so I thought I'd check in with the experts. I'm not overly fussed about the best or fastest way to do things just yet. I'm happy enough if something just works.

Thanks all! :)


Code: [Select]


;;;;;;;;;;;;;;;;;;;;;
;;;; TEST TASK 1 ;;;;
;;;;;;;;;;;;;;;;;;;;;


   org &8000


   textink      equ &BC32
   pixelposition   equ &BC1D


   ;jp MAIN
   
MAIN:
       
       call SCREENMODE   
   call BORDER
   call CLEARSCREEN
   call PIXELDRAW                 
   
RET   ;END OF MAIN




;;;;;;;;;;;;;;;;;;;;;;;;
;;;; LABELS TO CALL ;;;;
;;;;;;;;;;;;;;;;;;;;;;;;


SCREENMODE:


   ld a,0      ; a hold the value of the screen number to be used next
       call &BC0e   ; &bc0e   sets the screed mode ('a' sets screen mode and 'a' is 0)
   ret


CLEARSCREEN:
   
   ld hl,&C000   ; HL is start address of block
   ld e,l      ; DE = HL + 1
   ld d,h
   inc de   
   ld (hl),&00   ; Initialise first byte of block with data byte (&00)   
         ; HL + BC-1 = end address of block
   ld bc,&ffff   ; BC is length of block in bytes   
   ldir      ; Fill memory positions
   jr z,PIXELDRAW
   ret


BORDER:


   ld bc,&0000   ; Value of the border colour (e.g. &0000 = black &0101 = blue)
   call &BC38   ; &bc38 sets the border colour according to the value in bc
   ret


PIXELDRAW:


   ld de, &0508
   ld hl, &c100
   ld bc, &0202
   call pixelposition
     
   ;ld a,1
   ;ld bc,&0606
   ;call textink
   ld bc, &0505   
   ld hl, &C100   ; Screen memory address
   call &BC5C   ;&BC5C draws pixel on screen
   ret
Unlocking the dark arts of assembly!

Offline andycadley

  • Supporter
  • 6128 Plus
  • *
  • Posts: 940
  • Liked: 462
  • Likes Given: 75
Re: Help with a little screen test task
« Reply #1 on: 21:17, 24 April 19 »
Your ClearScreen routine is filling &FFFF bytes with 0, that's 65536 or 64K. In other words, it's wiping the entire RAM.

Offline Kitsune Mifune

  • CPC464
  • **
  • Posts: 36
  • Country: scotland
  • On a retro game making bucket list
  • Liked: 8
  • Likes Given: 6
Re: Help with a little screen test task
« Reply #2 on: 08:57, 26 April 19 »
Your ClearScreen routine is filling &FFFF bytes with 0, that's 65536 or 64K. In other words, it's wiping the entire RAM.

Ahh I figured it was something like that. Just wasn't sure so thanks for confirming.
Unlocking the dark arts of assembly!