• Welcome to Schneider / Amstrad CPC Forum.
Welcome to Schneider / Amstrad CPC Forum. Please login.

08. October 2025, 10:56:05

Login with username, password and session length

Shoutbox

TFM

2024-04-08, 20:42:44
Happy Sonnenfinsternis!  :)

TFM

2024-01-15, 17:06:57
Momentan billige Farbbänder auf Ebay für PCW

Devilmarkus

2023-07-09, 10:37:40
Zweiter 👋😂🤣

TFM

2023-06-13, 14:21:49
Sommerloch!

Recent

Members
Stats
  • Total Posts: 12,395
  • Total Topics: 1,449
  • Online today: 553
  • Online ever: 1,724
  • (16. January 2020, 00:18:45)
Users Online
Users: 1
Guests: 560
Total: 561

560 Guests, 1 User
TFM

Schnittpunkt

Started by EBO, 10. March 2025, 23:38:58

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

EBO

Ich suche eine Formel in Basic wie man den Schnittpunkt von der x-Achse Hex und die y-Achse auch Hex berechnen, das Ergebnis Mus auch in Hex sein 4 stellen

TFM

Der Schnittpunkt von X- und Y-Achse liegt bei 0,0 oder in Hex: &0000,&0000. Aber das wirst Du wohl nicht meinen, also...

Bei welcher Formel? Kannst Du das genauer ausführen?
TFM of FutureSoft
http://www.futureos.de --> Das Betriebssystem FutureOS (Update: 27.10.2024)
http://futureos.cpc-live.com/files/LambdaSpeak_RSX_by_TFM.zip --> RSX ROM für LambdaSpeak (Update: 26.12.2021)

BadCPC

Was er meint plot x,y: wie ist da die Screenadresse &C000-&FFFF
Hab da schon was mit &BC1D probiert, bekomme da aberirgendwie was falsch zurück geliefert ;)

BadCPC

hab da mal ein kleines mc-zu geschrieben, aber irgenwie verkehrter wert, vieleicht hab ich da noch nen denkfehler

; playing with &BC1D SCR_DOT_POSITION
; emtry
; HL = holds Y -Cordinate of the dot
; DE = holds X -Coordinate of the dot
; exit
; HL hols the memoryaddresse of the dot
; should be between &C000 and &FFFF
; call &8000,x,y,@n%
; @n% holds now the memoryaddresse of the dot pixel
;
; entrys on ix n,y,x
; so this would be
scr_dot_pos equ &BC1D
gra_plot_absolute equ &BBEA
org &8000



ld h,(ix+3) ; highbyte of y
ld l,(ix+2) ; lowbyte of y
ld d,(ix+5) ; highbyte of x
ld e,(ix+4) ; lowbyte of x
call gra_plot_absolute

ld h,(ix+3) ; highbyte of y
ld l,(ix+2) ; lowbyte of y
ld d,(ix+5) ; highbyte of x
ld e,(ix+4) ; lowbyte of x
call scr_dot_pos  ; call the firmware scr_dot_position
ex de,hl ; store hl to de
ld h,(ix+1) ; memory location of n highbyte
ld l,(ix+0) ; memory location of n lowbyte
ld (hl),d
inc hl
ld (hl),e
ret

BadCPC

#4
So musste feststellen das es mit &BC1D nicht funktionert,habe deswegen was neues gemacht;




org &8000
; diese routine gibt zu jedem plot x,y wert
; 1. die screenadresse &C000 - &FFFF zurück
; 2. das aktuelle byte an der dieser addresse
; 3. ein poke an die gewünschte addresse kann direkt über die variable erfolgen
;
scr_get_mode equ &BC11
scr_prev_line equ &BC29
start_scr_adr equ &FF80  ; start is bottom left for 0,0
              call scr_get_mode
              ld (mode),a
              ld a,(&B6A3)
;get y from ix
              ld h,(ix+1)
              ld l,(ix+0)
              ld de,2
              call div_2
              ld hl,start_scr_adr
;get screenaddres for y  0-399
repeat          push bc
                push de
                push af
                call scr_prev_line ;hl hold now the prev line in this case &FF80-
                pop af
                pop de
                pop bc
                ;ld (hl),a ; write pixel to screen
                ;ld (scr_adr),hl
                dec c
                jr nz, repeat
;djnz repeat
                ld (hight),hl
;add the x to these 0-639               
                ;ld hl,320
                ld h,(ix+3)
                ld l,(ix+2)
                ld e,8
                call div_2  
                ld hl,(hight)
                add hl,bc
                ld (scr_adr),hl
                ld a,(hl)
                ld (pixel),a
                ex de,hl
                ld l,(ix+6)
                ld h,(ix+7)
                ld (hl),e
                inc hl
                ld (hl),d
                ld l,(ix+4)
                ld h,(ix+5)
                ld (hl),a


ret
div_2
 ;ld de,2
Divide:                          ; this routine performs the operation BC=HL/E
  ld a,e                         ; checking the divisor; returning if it is zero
  or a                           ; from this time on the carry is cleared
  ret z
  ld bc,-1                       ; BC is used to accumulate the result
  ld d,0                         ; clearing D, so DE holds the divisor
DivLoop:                         ; subtracting DE from HL until the first overflow
  sbc hl,de                      ; since the carry is zero, SBC works as if it was a SUB
  inc bc                         ; note that this instruction does not alter the flags
  jr nc,DivLoop                  ; no carry means that there was no overflow
  ret


hight dw 0
with dw 0
scr_adr dw 0
mode db &0
pixel db 0



und der Basic-part

1 MEMORY &7FFF
2 LOAD"scradr.bin",&8000
4 scradr%=&FF80
5 pixel%=0
10 x%=320:y%=200
20 BORDER 0: GRAPHICS PEN 1
30 MODE 2: PLOT x%,y%
40 PRINT "Hex :"+HEX$(x%,4),+HEX$(y%,4)
50 IF INKEY(0)=0 THEN y%=y%+2:GOSUB 110
60 IF INKEY(1)=0 THEN x%=x%+2:GOSUB 110
70 IF INKEY(2)=0 THEN y%=y%-2:GOSUB 110
80 IF INKEY(8)=0 THEN x%=x%-2:GOSUB 110
90  IF INKEY(9)=0 THEN LOCATE 1,1:PRINT "Hex:"+HEX$(x%,4),+HEX$(y%,4)
100 GOTO 50
110 IF TEST(x%,y%)=1 THEN LOCATE 20,1:PRINT "Hex :"+HEX$(x%,4),+HEX$(y%,4)
111 CALL &8000,@scradr%,@pixel%,x%,y%
112 LOCATE 40,1:PRINT HEX$(scradr%,4);" ";BIN$(pixel%,8)
120 PLOT x%,y%   
130 RETURN

so kann gerene gegengeprüft werden , falls ich da noch einen fehler drin habe ;)