Оберон-клуб «ВЄДАsoft»

Твердыня модульных языков
Текущее время: 19 июн 2025, 00:20

Часовой пояс: UTC + 2 часа




Начать новую тему Ответить на тему  [ Сообщений: 20 ]  На страницу Пред.  1, 2
Автор Сообщение
 Заголовок сообщения: Re: lots of code,
СообщениеДобавлено: 19 июн 2013, 02:30 
Не в сети

Сообщения: 104
ok it works after I import xdev.lib

Have you tried doing any input?

I tried PEEKING 23560 to see the last key pressed but it doesnt seem to work


and how do I enable the fast print function?


Вернуться к началу
 Профиль  
Ответить с цитатой  
 Заголовок сообщения: Re: lots of code,
СообщениеДобавлено: 19 июн 2013, 12:00 
Не в сети
Аватара пользователя

Сообщения: 1019
Откуда: Днепропетровская обл.
slenkar писал(а):
ok it works after I import xdev.lib
Yes, ENTIER implemented in SYSTEM.c that is a part of xdev.lib which is designed as an universal and cross-platform runtime and set of modules (SYSTEM, Platform, Console, Math (in future - CmdLine, GrPixel, GrTiles, GrSprites, Control, Keyboard etc)).

slenkar писал(а):
Have you tried doing any input?

I tried PEEKING 23560 to see the last key pressed but it doesnt seem to work
It's because interrupts are disabled by Basic.Init:
Код: "C"
void Basic_Init (void)
{
__asm
DI
LD IY,#0x5C3A
RES 4,1(IY) /* RESET OF 128K FLAG */
__endasm;
} //Basic_Init
And it's done because SDCC actively used IY in generated code. You can to experience with IM 2 mode (with saving IY and calling an interrupt routine manually) or disable SDCC using IY for generated code.

1. To have IM 2 mode, use Basic initializer such:
Код: "C"
void Basic__init(void)
{
__asm
; ************************************************
; * Set IM2 mode (need for correct work with IY) *
; ************************************************
LD HL,#IM2PROC$
IMON$:
LD A,#24 ; код команды JR
LD (#65535),A
LD A,#195 ; код команды JP
LD (#65524),A
LD (#65525),HL ; в HL - адрес обработчика прерываний
LD HL,#0xFE00 ; построение таблицы для векторов прерываний
LD DE,#0xFE01
LD BC,#256 ; размер таблицы минус 1
LD (HL),#0xFF ; адрес перехода #FFFF (65535)
LD A,H ; запоминаем старший байт адреса таблицы
LDIR ; заполняем таблицу
DI ; запрещаем прерывания на время
; установки второго режима
LD I,A ; задаем в регистре I старший байт адреса
; таблицы для векторов прерываний
IM 2 ; назначаем второй режим прерываний
EI ; разрешаем прерывания
RET
 
IM2PROC$:
PUSH AF
PUSH HL
LD HL,(#0x5C78) ;
INC HL ; INC(FRAMES_CNTR)
LD (#0x5C78),HL ;
POP HL
POP AF
EI
__endasm;
} //Basic__init
Here is only work with timer. To use LAST_K (PEEKING 23560) you need to call ZX Basic interrupt handler. But all this questions are well known for Speccy fans.

2. Disable SDCC using IY for generated code. Use option --reserve-regs-iy and mode IM 0 (IM 1). IY must always = 0x5C3A. You'll need to remove DI from Basic_Init.

Probably, in the future I will add to Basic.lib support for the work in different interrupt modes (IM 0, IM 2). Maybe your work and written code will be useful too. :)

slenkar писал(а):
and how do I enable the fast print function?
Remark the line "#define ROM_OUTPUT" in ZXDev/Obj/BasicCfg.h


Вернуться к началу
 Профиль  
Ответить с цитатой  
 Заголовок сообщения: Re: lots of code,
СообщениеДобавлено: 19 июн 2013, 22:14 
Не в сети
Аватара пользователя

Сообщения: 1019
Откуда: Днепропетровская обл.
I just added to Lib/Basic the possbility to work in IM 0 and IM 2 modes. Try to use.

Little demo looks so:
Код: "OBERON"
  1. (* This program works when used #define MODE_IM2 in Obj/BasicCfg.h *)
  2. MODULE IM2;
  3. IMPORT B := Basic;
  4. CONST
  5. LAST_K = 5C08H; FRAMES_CNTR = 5C78H;
  6. BEGIN (*$MAIN*)
  7. B.Init;
  8. B.POKE(LAST_K, 0); B.AT(0, 0); B.PRSTR("Press SPACE to exit");
  9. REPEAT
  10. B.AT(4, 4); B.PRINT(B.PEEK(LAST_K)); B.PRSTR(" ");
  11. B.AT(8, 8); B.PRINT(B.PEEK(FRAMES_CNTR)); B.PRSTR(" ");
  12. UNTIL B.PEEK(LAST_K) = 20H;
  13. B.Quit;
  14. END IM2.
We need, of course, to have other procedures to check keys (now you can use direct reading from ports 0FEH and 1FH with help of Basic.PORTIN). I just have no ideas how to implement Basic's INKEY or INPUT. ;) though ... maybe use ROM subroutine 0x28E?

P.S. Original Templ's Ofront for Linux does not support character "_" in identifiers, so don't be surprised.


Вернуться к началу
 Профиль  
Ответить с цитатой  
 Заголовок сообщения: Re: lots of code,
СообщениеДобавлено: 19 июн 2013, 23:09 
Не в сети

Сообщения: 104
thanks nice demo!

I dont know if INKEY is necessary, people can write their own version if they want it.
(using peek 23560).

Did you put your interrupt table into RAM?
Did you used to program spectrums with assembly in the past? You seem good at it.

I would have great difficulty making an interrupt table

I changed the code to make it compile:
Код: "OBERON"
  1.  
  2. (* This program works when used #define MODE_IM2 in Obj/BasicCfg.h *)
  3. MODULE IM2;
  4. IMPORT B := Basic;
  5. CONST
  6. LASTK = 5C08H; FRAMESCNTR = 5C78H;
  7. BEGIN (*$MAIN*)
  8. B.Init;
  9. B.POKE(LASTK, 0); B.AT(0, 0); B.PRSTR("Press SPACE to exit");
  10. REPEAT
  11. B.AT(4, 4); B.PRINT(B.PEEK(LASTK)); B.PRSTR(" ");
  12. B.AT(8, 8); B.PRINT(B.PEEK(FRAMESCNTR)); B.PRSTR(" ");
  13. UNTIL B.PEEK(LASTK) = 20H;
  14. B.Quit;
  15. END IM2.


The program didnt start when I placed the code at 26000

WHen I placed the code and data in the same place as you I get a white screen but no text


Вернуться к началу
 Профиль  
Ответить с цитатой  
 Заголовок сообщения: Re: lots of code,
СообщениеДобавлено: 20 июн 2013, 00:33 
Не в сети
Аватара пользователя

Сообщения: 1019
Откуда: Днепропетровская обл.
slenkar писал(а):
Did you put your interrupt table into RAM?
Yes, at 0xFE00-0xFEFF.

slenkar писал(а):
Did you used to program spectrums with assembly in the past?
Yes, I wrote two games: "Tiny Tetris" in 1995 and "Sea Fight" in 1997. Since the games are open source, you can download sources of the games from WoS too.

slenkar писал(а):
The program didnt start when I placed the code at 26000
I have tried to place the code at 26000 and all is worked, no problems at all. Used this script:
Код: "BAT"
@SET Mod=IM2
@SET Bin=..\Bin
@SET Lib=..\Lib
@SET CodeAddr=26000
@SET DataAddr=60000
 
%Bin%\sdcc %Mod%.c -mz80 --code-loc %CodeAddr% --data-loc %DataAddr% --no-std-crt0 --opt-code-size --funsigned-char --disable-warning 126 -I "." -I %Lib% -L %Lib%/z80 Basic.lib XDev.lib
@IF errorlevel 1 PAUSE
 
@REM Convert Intel hex format to binary
@REM ==================================
%Bin%\hex2bin %Mod%.ihx
%Bin%\bin2data.exe -rem -org %CodeAddr% %Mod%.bin ..\%Mod%.tap %Mod%
@START ..\%Mod%.tap

slenkar писал(а):
WHen I placed the code and data in the same place as you I get a white screen but no text
And do you re-download Basic.h, Basic.c and Basic.lib? And switch on mode IM 2 by comment the line #define MODE_DI and uncomment the line #define MODE_IM2 in 'Obj/BasicCfg.h'?


Вернуться к началу
 Профиль  
Ответить с цитатой  
 Заголовок сообщения: Re: lots of code,
СообщениеДобавлено: 20 июн 2013, 03:01 
Не в сети

Сообщения: 104
Aha! I had to recompile Basic.lib,
the one from github had Interrupts disabled, it works great now thanks.

Im gonna check out those speccy games too


Вернуться к началу
 Профиль  
Ответить с цитатой  
 Заголовок сообщения: Re: lots of code,
СообщениеДобавлено: 20 июн 2013, 14:05 
Не в сети
Аватара пользователя

Сообщения: 1019
Откуда: Днепропетровская обл.
Recompilation of Basic.lib is not needed when you change options in BasicGfg.h
Earlier vers. of Basic.lib, of course, not supports IM 2 mode, therefore I've recommended to re-download the library (this feature was added just yesterday).

Yes, you see so much work can be done, how many directions. Perhaps together we will add the needed features into ZXDev.

P.S. I've fixed procedures PAUSE and BEEP to correct work in IM 0/IM 2 interrupt modes.


Вернуться к началу
 Профиль  
Ответить с цитатой  
 Заголовок сообщения: Re: lots of code,
СообщениеДобавлено: 21 июн 2013, 20:36 
Не в сети

Сообщения: 104
thanks,
I tried the tetris game and its a good version!

Did you use the spectrum to develop the game or a PC?


Вернуться к началу
 Профиль  
Ответить с цитатой  
 Заголовок сообщения: Re: lots of code,
СообщениеДобавлено: 21 июн 2013, 22:09 
Не в сети
Аватара пользователя

Сообщения: 1019
Откуда: Днепропетровская обл.
Both of my games are developed on real Spectrum clone "Orel BK-08" (Dnepropetrovsk variant) with black-white TV and cassete tape-recorder. :) "Tiny Tetris" is written in Basic and assembler for Spectrum 16K. "Sea Fight" is written in language COLOSS for "Orel BK-08", but can be launched under any clone of Spectrum 48K. The last game is in Russian.

Last several years I'm very impressed and specially interested in development in high-level programming languages. For example, did you see the game "Souls" that is written in Basic! Too interesting game. Would not bad to rewrite it to Oberon. ;)

Download game "Souls" and the Basic sources


Вернуться к началу
 Профиль  
Ответить с цитатой  
 Заголовок сообщения: Re: lots of code,
СообщениеДобавлено: 23 июн 2013, 03:41 
Не в сети

Сообщения: 104
Yes souls was impressive,
I played that for a while


Вернуться к началу
 Профиль  
Ответить с цитатой  
Показать сообщения за:  Поле сортировки  
Начать новую тему Ответить на тему  [ Сообщений: 20 ]  На страницу Пред.  1, 2

Часовой пояс: UTC + 2 часа


Кто сейчас на конференции

Сейчас этот форум просматривают: нет зарегистрированных пользователей и гости: 3


Вы не можете начинать темы
Вы не можете отвечать на сообщения
Вы не можете редактировать свои сообщения
Вы не можете удалять свои сообщения
Вы не можете добавлять вложения

Найти:
Перейти:  
cron
Создано на основе phpBB® Forum Software © phpBB Group
© VEDAsoft Oberon Club