Include Text Capture by Eric Eve.
There is a room.
When play begins:
start capturing text;
say "[unicode 301]";
stop capturing text;
say "[captured text]";
say "[unicode 301]";
Text Capture (by Eric Eve) doesn’t handle unicode, consequently i’m trying to adapt it, but unfortunately, i don’t have a clear idea of what I’m doing. I know that I should use glk_stream_open_memory_uni rather than glk_stream_open_memory, but I don’t really understand the mystical aspect of some opcodes (@push, @pull, @copy) nor have a good grasp at how arrays (bytes, words, multiplications and additions) work.
So here is a pale attempt (vaguely copied from Casting in IndexedText.i6t.
Include (-
#ifndef IT_MemoryBufferSize;
Constant IT_MemoryBufferSize = 512;
#endif;
Constant IT_Memory_NoBuffers = 2;
#ifndef IT_Memory_NoBuffers;
Constant IT_Memory_NoBuffers = 1;
#endif;
#ifdef TARGET_ZCODE;
Array IT_MemoryBuffer -> IT_MemoryBufferSize*IT_Memory_NoBuffers; ! Where characters are bytes
#ifnot;
Array IT_MemoryBuffer --> (IT_MemoryBufferSize+2)*IT_Memory_NoBuffers; ! Where characters are words
#endif;
Global RawBufferAddress = IT_MemoryBuffer;
Global RawBufferSize = IT_MemoryBufferSize;
Global old_stream = 0;
[ StartCapture i buffx buff str;
if (capture_active > 0) return;
old_stream = glk_stream_get_current();
buffx = (IT_MemoryBufferSize + 2)*WORDSIZE;
buff = RawBufferAddress;
str = glk_stream_open_memory_uni(buff, RawBufferSize, filemode_Write, 0);
glk_stream_set_current(str);
capture_active = 1;
];
[ EndCapture results buffx buff;
buffx = (IT_MemoryBufferSize + 2)*WORDSIZE;
buff = RawBufferAddress;
if (capture_active == 0) return;
print (char) 255; !add end of string marker
results = buff + buffx - 2*WORDSIZE;
glk_stream_close(glk_stream_get_current(), results);
set_cur_stream(old_stream);
capture_active = 0;
];
-).
Include (-
[ PrintCapture i j ch;
j = captured_text-->0;
for (i=WORDSIZE:i<(j+WORDSIZE):i++){
ch = captured_text->i;
if(ch== 0 or 255) break;
else if(ch ~= 10 || i>WORDSIZE) {
if (unicode_gestalt_ok) glk_put_char_uni(ch);
}
}
];
-).
I would highly appreciate any sort of help. Thanks